🪢 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
refactor: Remove intra-module barrels (#19227)
Ben Bachem763a8488e499
diff --git a/ee/eslint.config.mjs b/ee/eslint.config.mjsindex 5f72908ebe..2f597ef7e1 100644--- a/ee/eslint.config.mjs+++ b/ee/eslint.config.mjs@@ -1,3 +1,11 @@import baseConfig from "@repo/eslint-config";-export default [...baseConfig];+export default [+ ...baseConfig,+ {+ name: "langfuse/ee/package-entrypoints",+ // Public index entrypoints declared in this package's exports map.+ files: ["src/index.ts", "src/sso/index.ts"],+ rules: { "@repo/no-internal-barrel-files": "off" },+ },+];diff --git a/packages/config-eslint/next.js b/packages/config-eslint/next.jsindex f30ede2afa..c1efe6a882 100644--- a/packages/config-eslint/next.js+++ b/packages/config-eslint/next.js@@ -126,6 +126,13 @@ export default [...sharedConfig,+ // Next.js discovers routes by filename, not imports.+ {+ name: "langfuse/next/route-entrypoints",+ files: ["src/pages/**/*.{js,jsx,ts,tsx}"],+ rules: { "@repo/no-internal-barrel-files": "off" },+ },+{name: "langfuse/next/no-let-assign-in-react",files: ["**/*.{js,jsx,mjs,ts,tsx,mts,cts}"],diff --git a/packages/config-eslint/shared.js b/packages/config-eslint/shared.jsindex af745bc7b5..6f9e7233a0 100644--- a/packages/config-eslint/shared.js+++ b/packages/config-eslint/shared.js@@ -48,6 +48,18 @@ export default [},},+ {+ name: "langfuse/shared/no-internal-barrel-files",+ files: ["**/index.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],+ ignores: [+ "**/*.{test,spec,clienttest,servertest,stories,story}.{js,jsx,mjs,cjs,ts,tsx,mts,cts}",+ "**/{__tests__,__mocks__,tests,test,__stories__,stories}/**",+ ],+ rules: {+ "@repo/no-internal-barrel-files": "error",+ },+ },+{name: "langfuse/shared/typescript-rules",files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],diff --git a/packages/eslint-plugin/src/index.ts b/packages/eslint-plugin/src/index.tsindex 446b24f14e..e4b6eca82b 100644--- a/packages/eslint-plugin/src/index.ts+++ b/packages/eslint-plugin/src/index.ts@@ -19,8 +19,11 @@ import { default as storybookPlayRequiresTestName } from "./rules/storybook-playimport { default as preferStoriesOverClientTests } from "./rules/prefer-stories-over-client-tests.js";import { default as storybookPlayNoImplementationDetailAssertions } from "./rules/storybook-play-no-implementation-detail-assertions.js";+import noInternalBarrelFiles from "./rules/no-internal-barrel-files.js";+const plugin = {rules: {+ "no-internal-barrel-files": noInternalBarrelFiles,"component-file-structure": componentFileStructure,"no-abstracted-overlay-trigger": noAbstractedOverlayTrigger,"no-arbitrary-colors": noArbitraryColors,diff --git a/packages/eslint-plugin/src/rules/no-internal-barrel-files.test.ts b/packages/eslint-plugin/src/rules/no-internal-barrel-files.test.tsnew file mode 100644index 0000000000..aa30fb5b4b--- /dev/null+++ b/packages/eslint-plugin/src/rules/no-internal-barrel-files.test.ts@@ -0,0 +1,65 @@+import path from "node:path";+import { RuleTester } from "@typescript-eslint/rule-tester";+import * as parser from "@typescript-eslint/parser";+import rule from "./no-internal-barrel-files.js";++const directory = "/repo";++const tester = new RuleTester({ languageOptions: { parser } });+tester.run("no-internal-barrel-files", rule, {+ valid: [+ {+ code: "export const value = 1;",+ filename: path.join(directory, "src/value.ts"),+ },+ {+ code: 'export { value } from "./value"; export const local = 1;',+ filename: path.join(directory, "src/index.ts"),+ },+ { code: "", filename: path.join(directory, "src/empty.ts") },+ { code: "export {};", filename: path.join(directory, "src/module.ts") },+ {+ code: 'import "./setup"; export * from "./value";',+ filename: path.join(directory, "src/setup.ts"),+ },+ {+ code: "export default function value() {}",+ filename: path.join(directory, "src/value.ts"),+ },+ {+ code: "const value = 1; export { value };",+ filename: path.join(directory, "src/value.ts"),+ },+ {+ code: 'console.log("side effect"); export * from "./value";',+ filename: path.join(directory, "src/setup.ts"),+ },+ ],+ invalid: [+ ...[+ 'export * from "./value";',+ 'export { value as alias } from "./value";',+ 'export type { Value } from "./types";',+ 'export * as values from "./value";',+ 'export { default } from "./value";',+ '"use client"; export { value } from "./value";',+ 'import { value } from "./value"; export { value };',+ 'import type { Value } from "./types"; export type { Value };',+ 'import Value from "./value"; export default Value;',+ ].map((code) => ({+ code,+ filename: path.join(directory, "src/features/example/index.ts"),+ errors: [{ messageId: "unexpected" as const }],+ })),+ {+ code: 'export * from "./value";',+ filename: path.join(directory, "src/features/example/surface.ts"),+ errors: [{ messageId: "unexpected" }],+ },+ ...["src/index.ts", "web/src/pages/example/index.tsx"].map((filename) => ({+ code: 'export * from "./value";',+ filename: path.join(directory, filename),+ errors: [{ messageId: "unexpected" as const }],+ })),+ ],+});diff --git a/packages/eslint-plugin/src/rules/no-internal-barrel-files.ts b/packages/eslint-plugin/src/rules/no-internal-barrel-files.tsnew file mode 100644index 0000000000..3123a33323--- /dev/null+++ b/packages/eslint-plugin/src/rules/no-internal-barrel-files.ts@@ -0,0 +1,53 @@+import { createRule } from "../util.js";++export default createRule({+ name: "no-internal-barrel-files",+ meta: {+ type: "problem",+ docs: {+ description: "Use direct imports instead of internal re-export barrels.",+ },+ messages: {+ unexpected:+ "Internal barrel files expand dependency graphs. Import from the defining files instead; only package and framework entry points may be barrels.",+ },+ schema: [],+ },+ defaultOptions: [],+ create(context) {+ return {+ Program(node) {+ let hasExports = false;+ for (const statement of node.body) {+ if (statement.type === "ExportAllDeclaration") {+ hasExports = true;+ continue;+ }+ if (statement.type === "ExportNamedDeclaration") {+ if (statement.declaration) return;+ if (statement.specifiers.length > 0) hasExports = true;+ continue;+ }+ if (statement.type === "ExportDefaultDeclaration") {+ if (statement.declaration.type !== "Identifier") return;+ hasExports = true;+ continue;+ }+ if (statement.type === "ImportDeclaration") {+ if (statement.specifiers.length === 0) return;+ continue;+ }+ if (+ statement.type === "ExpressionStatement" &&+ typeof statement.directive === "string"+ ) {+ continue;+ }+ return;+ }++ if (hasExports) context.report({ node, messageId: "unexpected" });+ },+ };+ },+});diff --git a/packages/shared/eslint.config.mjs b/packages/shared/eslint.config.mjsindex 5f72908ebe..ca27f1e199 100644--- a/packages/shared/eslint.config.mjs+++ b/packages/shared/eslint.config.mjs@@ -1,3 +1,31 @@import baseConfig from "@repo/eslint-config";-export default [...baseConfig];+export default [+ ...baseConfig,+ {+ name: "langfuse/shared/package-entrypoints",+ // Public index entrypoints declared in this package's exports map.+ files: [+ "src/index.ts",+ "src/server/index.ts",+ "src/server/clickhouse/index.ts",+ "src/server/instrumentation/bootstrap/index.ts",+ "src/utils/chatml/index.ts",+ "src/utils/normalized-io/index.ts",+ "src/encryption/index.ts",+ "src/server/ee/ingestionMasking/index.ts",+ "src/server/ee/fips/index.ts",+ "src/server/ee/licenseCheck/index.ts",+ "src/server/ee/clickhouseBilling/index.ts",+ "src/features/query/index.ts",+ "src/features/rbac/index.ts",+ "src/features/query/server/index.ts",+ "src/features/monitors/index.ts",+ "src/features/pagerduty/index.ts",+ "src/in-app-agent/index.ts",+ "src/topics/index.ts",+ "src/server/topics/index.ts",+ ],+ rules: { "@repo/no-internal-barrel-files": "off" },+ },+];diff --git a/packages/shared/scripts/seeder/scenarios/agent-graph.ts b/packages/shared/scripts/seeder/scenarios/agent-graph.tsindex d15992b44c..744e12a9f4 100644--- a/packages/shared/scripts/seeder/scenarios/agent-graph.ts+++ b/packages/shared/scripts/seeder/scenarios/agent-graph.ts@@ -6,7 +6,7 @@ import {createEventsCh,ObservationRecordInsertType,} from "../../../src/server";-import { ObservationType } from "../../../src/domain";+import { ObservationType } from "../../../src/domain/observations";import { observationToEvent, traceToEvent } from "./event-mirror";import { buildPayload, generationUsageCost } from "./payload";import { jitter, Rng, utcDayStartMs } from "./rng";diff --git a/packages/shared/scripts/seeder/scenarios/agent-timeline.ts b/packages/shared/scripts/seeder/scenarios/agent-timeline.tsindex eb2af80303..1ec38e64a7 100644--- a/packages/shared/scripts/seeder/scenarios/agent-timeline.ts+++ b/packages/shared/scripts/seeder/scenarios/agent-timeline.ts@@ -7,7 +7,7 @@ import {createEventsCh,ObservationRecordInsertType,} from "../../../src/server";-import { ObservationType } from "../../../src/domain";+import { ObservationType } from "../../../src/domain/observations";import { observationToEvent, traceToEvent } from "./event-mirror";import { buildPayload, generationUsageCost } from "./payload";import { jitter, Rng, utcDayStartMs } from "./rng";diff --git a/packages/shared/scripts/seeder/scenarios/incident-session.ts b/packages/shared/scripts/seeder/scenarios/incident-session.tsindex 56a61a9eb6..a809d4564d 100644--- a/packages/shared/scripts/seeder/scenarios/incident-session.ts+++ b/packages/shared/scripts/seeder/scenarios/incident-session.ts@@ -16,7 +16,7 @@ import {ScoreRecordInsertType,TraceRecordInsertType,} from "../../../src/server";-import { ObservationType } from "../../../src/domain";+import { ObservationType } from "../../../src/domain/observations";import { observationToEvent, traceToEvent } from "./event-mirror";import { utcDayStartMs } from "./rng";import {diff --git a/packages/shared/scripts/seeder/scenarios/support-agent.ts b/packages/shared/scripts/seeder/scenarios/support-agent.tsindex 193fdfee3a..a55cafe750 100644--- a/packages/shared/scripts/seeder/scenarios/support-agent.ts+++ b/packages/shared/scripts/seeder/scenarios/support-agent.ts@@ -9,7 +9,7 @@ import {extractToolsFromObservation,ObservationRecordInsertType,} from "../../../src/server";-import { ObservationType } from "../../../src/domain";+import { ObservationType } from "../../../src/domain/observations";import { observationToEvent, traceToEvent } from "./event-mirror";import { utcDayStartMs } from "./rng";import {diff --git a/packages/shared/scripts/seeder/scenarios/timeline-annotated.ts b/packages/shared/scripts/seeder/scenarios/timeline-annotated.tsindex 6aa220f6c0..6e92ef6c22 100644--- a/packages/shared/scripts/seeder/scenarios/timeline-annotated.ts+++ b/packages/shared/scripts/seeder/scenarios/timeline-annotated.ts@@ -11,7 +11,7 @@ import {ScoreRecordInsertType,TraceRecordInsertType,} from "../../../src/server";-import { ObservationType } from "../../../src/domain";+import { ObservationType } from "../../../src/domain/observations";import { observationToEvent, traceToEvent } from "./event-mirror";import { generationUsageCost } from "./payload";import { utcDayStartMs } from "./rng";diff --git a/packages/shared/scripts/seeder/scenarios/timeline-shapes.ts b/packages/shared/scripts/seeder/scenarios/timeline-shapes.tsindex 453a0ea07d..b8f2361575 100644--- a/packages/shared/scripts/seeder/scenarios/timeline-shapes.ts+++ b/packages/shared/scripts/seeder/scenarios/timeline-shapes.ts@@ -8,7 +8,7 @@ import {ObservationRecordInsertType,TraceRecordInsertType,} from "../../../src/server";-import { ObservationType } from "../../../src/domain";+import { ObservationType } from "../../../src/domain/observations";import { observationToEvent, traceToEvent } from "./event-mirror";import { generationUsageCost } from "./payload";import { utcDayStartMs } from "./rng";diff --git a/packages/shared/scripts/seeder/scenarios/trace-tree.ts b/packages/shared/scripts/seeder/scenarios/trace-tree.tsindex f1aed2a3cb..2d1d4f6ec2 100644--- a/packages/shared/scripts/seeder/scenarios/trace-tree.ts+++ b/packages/shared/scripts/seeder/scenarios/trace-tree.ts@@ -10,7 +10,7 @@ import {ObservationRecordInsertType,ScoreRecordInsertType,} from "../../../src/server";-import { ObservationType } from "../../../src/domain";+import { ObservationType } from "../../../src/domain/observations";import { observationToEvent, traceToEvent } from "./event-mirror";import {buildPayload,diff --git a/packages/shared/src/domain/index.ts b/packages/shared/src/domain/index.tsdeleted file mode 100644index dc5f9be33d..0000000000--- a/packages/shared/src/domain/index.ts+++ /dev/null@@ -1,13 +0,0 @@-export * from "./observation-field-groups";-export * from "./export-field-groups";-export * from "./observations";-export * from "./traces";-export * from "./scores";-export * from "./table-view-presets";-export * from "./table-view-presets-catalog";-export * from "./automations";-export * from "./webhooks";-export * from "./prompts";-export * from "./dataset-items";-export * from "./media";-export * from "./auditLogs";diff --git a/packages/shared/src/errors/index.ts b/packages/shared/src/errors/index.tsdeleted file mode 100644index 76171be3a8..0000000000--- a/packages/shared/src/errors/index.ts+++ /dev/null@@ -1,17 +0,0 @@-export { BaseError, isBaseError } from "./BaseError";-export { LangfuseNotFoundError } from "./NotFoundError";-export { InvalidRequestError } from "./InvalidRequestError";-export { UnauthorizedError } from "./UnauthorizedError";-export { ForbiddenError } from "./ForbiddenError";-export { MethodNotAllowedError } from "./MethodNotAllowedError";-export { ApiError } from "./ApiError";-export { InternalServerError } from "./InternalServerError";-export { LangfuseConflictError } from "./ConflictError";-export { ServiceUnavailableError } from "./ServiceUnavailableError";-export { NotImplementedError } from "./NotImplementedError";-export { PayloadTooLargeError } from "./PayloadTooLargeError";-export { TooManyRequestsError } from "./TooManyRequestsError";-export { BadGatewayError } from "./BadGatewayError";-export { GatewayTimeoutError } from "./GatewayTimeoutError";-export { toBaseError } from "./toBaseError";-export * from "./errorMessages";diff --git a/packages/shared/src/eventsTable.ts b/packages/shared/src/eventsTable.tsindex c2d2d604ef..58cd41a648 100644--- a/packages/shared/src/eventsTable.ts+++ b/packages/shared/src/eventsTable.ts@@ -1,4 +1,4 @@-import { type ColumnDefinition } from "./tableDefinitions";+import type { ColumnDefinition } from "./tableDefinitions/types";export const eventsTableHasParentObservationSql = "e.parent_span_id != ''";export const eventsTableIsRootObservationSqlForAlias = (alias: string) => {diff --git a/packages/shared/src/features/annotation/types.ts b/packages/shared/src/features/annotation/types.tsindex 2a9b78173d..16fcf5e06d 100644--- a/packages/shared/src/features/annotation/types.ts+++ b/packages/shared/src/features/annotation/types.ts@@ -1,6 +1,6 @@import z from "zod";import { StringNoHTML, StringNoHTMLNonEmpty } from "../../utils/zod";-import { CategoricalData, TextData, NumericData } from "../../domain";+import { CategoricalData, TextData, NumericData } from "../../domain/scores";const ScoreTargetTrace = z.object({type: z.literal("trace"),diff --git a/packages/shared/src/features/evals/experimentFilters.ts b/packages/shared/src/features/evals/experimentFilters.tsindex cbb0392a3a..2b83f462dd 100644--- a/packages/shared/src/features/evals/experimentFilters.ts+++ b/packages/shared/src/features/evals/experimentFilters.ts@@ -1,7 +1,7 @@import type {ColumnDefinition,SingleValueOption,-} from "../../tableDefinitions";+} from "../../tableDefinitions/types";import { formatColumnOptions } from "../../tableDefinitions/typeHelpers";import {evalFilterFields,diff --git a/packages/shared/src/features/evals/filterFields.ts b/packages/shared/src/features/evals/filterFields.tsindex b689b2cf8f..9cee293eea 100644--- a/packages/shared/src/features/evals/filterFields.ts+++ b/packages/shared/src/features/evals/filterFields.ts@@ -1,6 +1,6 @@-import { ObservationLevel, ObservationType } from "../../domain";+import { ObservationLevel, ObservationType } from "../../domain/observations";import { isRootObservation } from "../../eventsTable";-import type { ColumnDefinition } from "../../tableDefinitions";+import type { ColumnDefinition } from "../../tableDefinitions/types";import type { FilterCondition } from "../../types";import type { ObservationForEval } from "./observationForEval";diff --git a/packages/shared/src/features/evals/observationForEval.ts b/packages/shared/src/features/evals/observationForEval.tsindex f8f8625f34..7e3e663826 100644--- a/packages/shared/src/features/evals/observationForEval.ts+++ b/packages/shared/src/features/evals/observationForEval.ts@@ -1,7 +1,7 @@import { z } from "zod";import { DEFAULT_TRACE_ENVIRONMENT } from "../../server/ingestion/types";import { type EventRecordBaseType } from "../../server/repositories/definitions";-import { ObservationLevel } from "../../domain";+import { ObservationLevel } from "../../domain/observations";import { metadataArraysToRecord } from "../../server/utils/metadata_conversion";import { parseJsonIfString } from "../../utils/json";diff --git a/packages/shared/src/features/evals/spanFilters.ts b/packages/shared/src/features/evals/spanFilters.tsindex b725211391..29e026a600 100644--- a/packages/shared/src/features/evals/spanFilters.ts+++ b/packages/shared/src/features/evals/spanFilters.ts@@ -1,7 +1,7 @@import type {ColumnDefinition,SingleValueOption,-} from "../../tableDefinitions";+} from "../../tableDefinitions/types";import { formatColumnOptions } from "../../tableDefinitions/typeHelpers";import {evalFilterFields,diff --git a/packages/shared/src/features/evals/validateEvaluatorFilters.ts b/packages/shared/src/features/evals/validateEvaluatorFilters.tsindex ad0f313757..8c5e3a8f33 100644--- a/packages/shared/src/features/evals/validateEvaluatorFilters.ts+++ b/packages/shared/src/features/evals/validateEvaluatorFilters.ts@@ -1,5 +1,5 @@import { singleFilterList } from "../../interfaces/filters";-import type { ColumnDefinition } from "../../tableDefinitions";+import type { ColumnDefinition } from "../../tableDefinitions/types";import {evalDatasetFormFilterCols,evalTraceTableCols,diff --git a/packages/shared/src/features/model-pricing/index.ts b/packages/shared/src/features/model-pricing/index.tsdeleted file mode 100644index 99455b8180..0000000000--- a/packages/shared/src/features/model-pricing/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./validation";diff --git a/packages/shared/src/features/monitors/server.ts b/packages/shared/src/features/monitors/server.tsindex 69f1e1f399..08bff2ac2d 100644--- a/packages/shared/src/features/monitors/server.ts+++ b/packages/shared/src/features/monitors/server.ts@@ -2,7 +2,33 @@* re-exports everything client-safe from `./index` plus the service and* scheduler DTOs. */export * from "./index";-export * from "./service";+export { MonitorService } from "./service/service";+export { MonitorNotFoundError } from "./service/types";+export { SessionContextSchema } from "./service/types";+export { type SessionContext } from "./service/types";+export { CreateMonitorSchema } from "./service/types";+export { type CreateMonitor } from "./service/types";+export { UpdateMonitorSchema } from "./service/types";+export { type UpdateMonitor } from "./service/types";+export { GetMonitorByIdSchema } from "./service/types";+export { type GetMonitorById } from "./service/types";+export { DeleteMonitorSchema } from "./service/types";+export { type DeleteMonitor } from "./service/types";+export { GetMonitorFilterOptionsSchema } from "./service/types";+export { type GetMonitorFilterOptions } from "./service/types";+export { MonitorListOrderBySchema } from "./service/types";+export { type MonitorListOrderBy } from "./service/types";+export { ListMonitorSeverityFilterSchema } from "./service/types";+export { type ListMonitorSeverityFilter } from "./service/types";+export { ListMonitorEvaluatorIdFilterSchema } from "./service/types";+export { type ListMonitorEvaluatorIdFilter } from "./service/types";+export { ListMonitorTagsFilterSchema } from "./service/types";+export { type ListMonitorTagsFilter } from "./service/types";+export { ErrorListMonitorFilterDuplicateColumn } from "./service/types";+export { ListMonitorFilterSchema } from "./service/types";+export { type ListMonitorFilter } from "./service/types";+export { ListMonitorsSchema } from "./service/types";+export { type ListMonitors } from "./service/types";export * from "./service/evaluatorFilterMatching";export * from "./scheduler/types";export * from "./scheduler/scheduler";diff --git a/packages/shared/src/features/monitors/service/helpers.test.ts b/packages/shared/src/features/monitors/service/helpers.test.tsindex d381d8aa37..328af1aac6 100644--- a/packages/shared/src/features/monitors/service/helpers.test.ts+++ b/packages/shared/src/features/monitors/service/helpers.test.ts@@ -3,7 +3,8 @@ import { MonitorView as PrismaMonitorView, Prisma } from "@prisma/client";import { describe, it, expect } from "vitest";import { z } from "zod";-import { InvalidRequestError, LangfuseNotFoundError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";+import { LangfuseNotFoundError } from "../../../errors/NotFoundError";import { singleFilter } from "../../../interfaces/filters";import {MonitorNoDataModeSchema,diff --git a/packages/shared/src/features/monitors/service/index.ts b/packages/shared/src/features/monitors/service/index.tsdeleted file mode 100644index d9846cf88b..0000000000--- a/packages/shared/src/features/monitors/service/index.ts+++ /dev/null@@ -1,5 +0,0 @@-/** service/index.ts is the MonitorService barrel — public DTOs and the- * service class. Mapping/calculate helpers in `./helpers` are intentionally- * not re-exported. */-export * from "./service";-export * from "./types";diff --git a/packages/shared/src/features/monitors/service/types.ts b/packages/shared/src/features/monitors/service/types.tsindex f58e4d26a4..5d4c31c93d 100644--- a/packages/shared/src/features/monitors/service/types.ts+++ b/packages/shared/src/features/monitors/service/types.ts@@ -1,7 +1,7 @@/** service/types.ts contains the DTOs, schemas, and errors for the MonitorService. */import { z } from "zod";-import { LangfuseNotFoundError } from "../../../errors";+import { LangfuseNotFoundError } from "../../../errors/NotFoundError";import { paginationZod } from "../../../utils/zod";import {diff --git a/packages/shared/src/features/monitors/types.ts b/packages/shared/src/features/monitors/types.tsindex 3a83365c87..7464084611 100644--- a/packages/shared/src/features/monitors/types.ts+++ b/packages/shared/src/features/monitors/types.ts@@ -7,7 +7,7 @@ import {} from "@prisma/client";import { z } from "zod";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import { singleFilterList } from "../../interfaces/filters";import { granularities, metric as MetricSchema, viewsV2 } from "../query/types";diff --git a/packages/shared/src/features/pagerduty/pagerDutyClient.ts b/packages/shared/src/features/pagerduty/pagerDutyClient.tsindex 0551c533c1..c74a086e52 100644--- a/packages/shared/src/features/pagerduty/pagerDutyClient.ts+++ b/packages/shared/src/features/pagerduty/pagerDutyClient.ts@@ -1,12 +1,10 @@import { backOff } from "exponential-backoff";-import {- GatewayTimeoutError,- isBaseError,- ServiceUnavailableError,- TooManyRequestsError,- toBaseError,-} from "../../errors";+import { GatewayTimeoutError } from "../../errors/GatewayTimeoutError";+import { isBaseError } from "../../errors/BaseError";+import { TooManyRequestsError } from "../../errors/TooManyRequestsError";+import { toBaseError } from "../../errors/toBaseError";+import { ServiceUnavailableError } from "../../errors/ServiceUnavailableError";import { logger } from "../../server/logger";import { type PagerDutyRegion } from "./types";diff --git a/packages/shared/src/features/query/dataModel.ts b/packages/shared/src/features/query/dataModel.tsindex d03536cacb..27030660f6 100644--- a/packages/shared/src/features/query/dataModel.ts+++ b/packages/shared/src/features/query/dataModel.ts@@ -6,7 +6,7 @@ import {type views,SCORES_LISTABLE_COUNT_VIEW,} from "./types";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import {eventsTableIsRootObservationSqlForAlias,eventsTableTraceNameAggregationSqlForAlias,diff --git a/packages/shared/src/features/query/server/queryBuilder.filterValidation.test.ts b/packages/shared/src/features/query/server/queryBuilder.filterValidation.test.tsindex b00f2b7331..dc9bd2c48a 100644--- a/packages/shared/src/features/query/server/queryBuilder.filterValidation.test.ts+++ b/packages/shared/src/features/query/server/queryBuilder.filterValidation.test.ts@@ -1,6 +1,6 @@import { describe, expect, it, vi } from "vitest";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import type { FilterCondition } from "../../../types";import { getViewDeclaration } from "../dataModel";import type { QueryType, ViewVersion } from "../types";diff --git a/packages/shared/src/features/query/server/queryBuilder.ts b/packages/shared/src/features/query/server/queryBuilder.tsindex 5b5f9a2c78..6885570deb 100644--- a/packages/shared/src/features/query/server/queryBuilder.ts+++ b/packages/shared/src/features/query/server/queryBuilder.ts@@ -11,21 +11,20 @@ import {type Filter,} from "../../../server/queries/clickhouse-sql/clickhouse-filter";import { createFilterFromFilterState } from "../../../server/queries/clickhouse-sql/factory";-import type {- QueryType,- ViewDeclarationType,- metricAggregations,- granularities,- ViewVersion,- views,-} from "../types";import {+ type QueryType,+ type ViewDeclarationType,+ type metricAggregations,+ type granularities,+ type ViewVersion,+ type views,query as queryModel,getValidAggregationsForMeasureType,SCORES_LISTABLE_COUNT_VIEW,} from "../types";+import { getViewDeclaration } from "../dataModel";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { env } from "../../../env";import { NULL_IF_EMPTY_RE } from "./nullIfEmptyFilter";import {diff --git a/packages/shared/src/features/rbac/roleAssignmentService.ts b/packages/shared/src/features/rbac/roleAssignmentService.tsindex 02362aeb5b..95516c6f6c 100644--- a/packages/shared/src/features/rbac/roleAssignmentService.ts+++ b/packages/shared/src/features/rbac/roleAssignmentService.ts@@ -4,7 +4,8 @@ import {type RoleAssignment as StoredRoleAssignment,} from "@prisma/client";-import { InvalidRequestError, NotImplementedError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";+import { NotImplementedError } from "../../errors/NotImplementedError";import { withTransaction } from "../../server/utils/withTransaction";import {hasApiKeyKind,diff --git a/packages/shared/src/features/scoreConfigs/index.ts b/packages/shared/src/features/scoreConfigs/index.tsdeleted file mode 100644index 99455b8180..0000000000--- a/packages/shared/src/features/scoreConfigs/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./validation";diff --git a/packages/shared/src/features/scores/index.ts b/packages/shared/src/features/scores/index.tsdeleted file mode 100644index a427c734fb..0000000000--- a/packages/shared/src/features/scores/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./interfaces";diff --git a/packages/shared/src/features/scores/interfaces/api/index.ts b/packages/shared/src/features/scores/interfaces/api/index.tsdeleted file mode 100644index 474d7cb572..0000000000--- a/packages/shared/src/features/scores/interfaces/api/index.ts+++ /dev/null@@ -1,8 +0,0 @@-export * from "./v1/schemas";-export * from "./v1/validation";-export * from "./v1/endpoints";-export * from "./v2/validation";-export * from "./v2/endpoints";-export * from "./v3/schemas";-export * from "./v3/endpoints";-export * from "./v3/validation";diff --git a/packages/shared/src/features/scores/interfaces/api/shared.ts b/packages/shared/src/features/scores/interfaces/api/shared.tsindex 689640e280..7327057cf2 100644--- a/packages/shared/src/features/scores/interfaces/api/shared.ts+++ b/packages/shared/src/features/scores/interfaces/api/shared.ts@@ -16,7 +16,7 @@ import {TEXT_SCORE_MAX_LENGTH,} from "../../../../domain/scores";import { singleFilterList } from "../../../../interfaces/filters";-import { InvalidRequestError } from "../../../../errors";+import { InvalidRequestError } from "../../../../errors/InvalidRequestError";const operators = ["<", ">", "<=", ">=", "!=", "="] as const;diff --git a/packages/shared/src/features/scores/interfaces/api/v2/schemas.ts b/packages/shared/src/features/scores/interfaces/api/v2/schemas.tsindex 281b41b0ab..6383f9dccf 100644--- a/packages/shared/src/features/scores/interfaces/api/v2/schemas.ts+++ b/packages/shared/src/features/scores/interfaces/api/v2/schemas.ts@@ -3,7 +3,7 @@ import {CategoricalData,NumericData,ScoreSchemaExclReferencesAndDates,-} from "../../../../../domain";+} from "../../../../../domain/scores";import z from "zod";// Response-only schemas without input validation constraints (e.g. length limits).diff --git a/packages/shared/src/features/scores/interfaces/application/validation.ts b/packages/shared/src/features/scores/interfaces/application/validation.tsindex 9d1769724a..6717f69fde 100644--- a/packages/shared/src/features/scores/interfaces/application/validation.ts+++ b/packages/shared/src/features/scores/interfaces/application/validation.ts@@ -5,7 +5,7 @@ import {ScoreSchema,ScoreDataTypeType,ScoresByDataTypes,-} from "../../../../domain";+} from "../../../../domain/scores";type ValidatedScore<IncludeHasMetadata extends boolean,diff --git a/packages/shared/src/features/scores/interfaces/index.ts b/packages/shared/src/features/scores/interfaces/index.tsdeleted file mode 100644index 64bb80d390..0000000000--- a/packages/shared/src/features/scores/interfaces/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export * from "./api";-export * from "./application/validation";-export * from "./ingestion/validation";-export * from "./ui/types";diff --git a/packages/shared/src/features/scores/interfaces/ui/types.ts b/packages/shared/src/features/scores/interfaces/ui/types.tsindex de74e4a0e5..854df81254 100644--- a/packages/shared/src/features/scores/interfaces/ui/types.ts+++ b/packages/shared/src/features/scores/interfaces/ui/types.ts@@ -1,8 +1,8 @@import {ListableScoreDataType,- MetadataDomain,ScoreSourceType,-} from "../../../../domain";+} from "../../../../domain/scores";+import { MetadataDomain } from "../../../../domain/traces";export type BaseAggregate = {comment?: string | null;diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.tsindex b72f4fdf44..af9cf2033e 100644--- a/packages/shared/src/index.ts+++ b/packages/shared/src/index.ts@@ -7,7 +7,39 @@ export * from "./interfaces/cloudConfigSchema";export * from "./interfaces/parseDbOrg";export * from "./interfaces/billingProvider";export * from "./interfaces/customLLMProviderConfigSchemas";-export * from "./tableDefinitions";+export { sessionsViewCols } from "./tableDefinitions/sessionsView";+export { sessionsEventsViewCols } from "./tableDefinitions/sessionsView";+export { type SessionOptions } from "./tableDefinitions/sessionsView";+export { sessionsTableColsWithOptions } from "./tableDefinitions/sessionsView";+export { type UiColumnMatchable } from "./tableDefinitions/types";+export { type UiColumnMappings } from "./tableDefinitions/types";+export { type UiColumnMapping } from "./tableDefinitions/types";+export { matchesUiColumnMapping } from "./tableDefinitions/types";+export { findUiColumnMapping } from "./tableDefinitions/types";+export { type SingleValueOption } from "./tableDefinitions/types";+export { type MultiValueOption } from "./tableDefinitions/types";+export { type OptionsDefinition } from "./tableDefinitions/types";+export { type ColumnDefinition } from "./tableDefinitions/types";+export { tableNames } from "./tableDefinitions/types";+export { type TableNames } from "./tableDefinitions/types";+export { type TableDefinitions } from "./tableDefinitions/types";+export { dashboardColumnDefinitions } from "./tableDefinitions/mapDashboards";+export { monitorsTableCols } from "./tableDefinitions/monitorsTable";+export { promptsTableCols } from "./tableDefinitions/promptsTable";+export { type PromptOptions } from "./tableDefinitions/promptsTable";+export { promptsTableColsWithOptions } from "./tableDefinitions/promptsTable";+export { webhookActionFilterOptions } from "./tableDefinitions/promptsTable";+export { datasetItemFilterColumns } from "./tableDefinitions/datasetItemsTable";+export { datasetRunsTableUiColumnDefinitions } from "./tableDefinitions/mapDatasetRunsTable";+export { isClickhouseFilterColumn } from "./tableDefinitions/datasetRunsTable";+export { datasetRunsTableCols } from "./tableDefinitions/datasetRunsTable";+export { type DatasetRunsOptions } from "./tableDefinitions/datasetRunsTable";+export { datasetRunsTableColsWithOptions } from "./tableDefinitions/datasetRunsTable";+export { datasetRunItemsTableCols } from "./tableDefinitions/datasetRunItemsTable";+export { type DatasetRunItemsOptions } from "./tableDefinitions/datasetRunItemsTable";+export { datasetRunItemsTableColsWithOptions } from "./tableDefinitions/datasetRunItemsTable";+export { usersTableCols } from "./tableDefinitions/usersTable";+export { scoresTableCols } from "./tableDefinitions/scoresTable";export * from "./types";export * from "./tableDefinitions/tracesTable";export * from "./observationsTable";@@ -74,10 +106,54 @@ export * from "./utils/dateRanges";export * from "./features/annotation/types";// scores-export * from "./features/scores";+export { APIScoreSchemaV1 } from "./features/scores/interfaces/api/v1/schemas";+export { type APIScoreV1 } from "./features/scores/interfaces/api/v1/schemas";+export { filterAndValidateLegacyV1GetScoreList } from "./features/scores/interfaces/api/v1/validation";+// eslint-disable-next-line @typescript-eslint/no-deprecated -- Preserve the existing package API for legacy consumers.+export { filterAndValidateV1GetScoreList } from "./features/scores/interfaces/api/v1/validation";+export { GetScoreQueryV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { GetScoreResponseV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { DeleteScoreQueryV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { DeleteScoreResponseV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { GetScoresQueryV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { GetScoreResponseDataV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { GetScoresResponseV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { PostScoreBodyV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { PostScoresBodyV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { PostScoresResponseV1 } from "./features/scores/interfaces/api/v1/endpoints";+export { filterAndValidateV2GetScoreList } from "./features/scores/interfaces/api/v2/validation";+export { GetScoreQueryV2 } from "./features/scores/interfaces/api/v2/endpoints";+export { GetScoreResponseV2 } from "./features/scores/interfaces/api/v2/endpoints";+export { GetScoresQueryV2 } from "./features/scores/interfaces/api/v2/endpoints";+export { GetScoreResponseDataV2 } from "./features/scores/interfaces/api/v2/endpoints";+export { GetScoresResponseV2 } from "./features/scores/interfaces/api/v2/endpoints";+export { ScoreSubjectV3 } from "./features/scores/interfaces/api/v3/schemas";+export { APIScoreSchemaV3 } from "./features/scores/interfaces/api/v3/schemas";+export { type APIScoreV3 } from "./features/scores/interfaces/api/v3/schemas";+export { SCORE_FIELD_GROUPS_V3 } from "./features/scores/interfaces/api/v3/endpoints";+export { type ScoreFieldGroupV3 } from "./features/scores/interfaces/api/v3/endpoints";+export { GetScoresQueryV3 } from "./features/scores/interfaces/api/v3/endpoints";+export { GetScoresResponseV3 } from "./features/scores/interfaces/api/v3/endpoints";+export { filterAndValidateV3GetScoreList } from "./features/scores/interfaces/api/v3/validation";+export { validateDbScore } from "./features/scores/interfaces/application/validation";+export { filterAndValidateDbScoreList } from "./features/scores/interfaces/application/validation";+export { filterAndValidateDbLegacyTraceScoreList } from "./features/scores/interfaces/application/validation";+// eslint-disable-next-line @typescript-eslint/no-deprecated -- Preserve the existing package API for legacy consumers.+export { filterAndValidateDbTraceScoreList } from "./features/scores/interfaces/application/validation";+export { ScoreBodyWithoutConfig } from "./features/scores/interfaces/ingestion/validation";+export { ScorePropsAgainstConfig } from "./features/scores/interfaces/ingestion/validation";+export { type BaseAggregate } from "./features/scores/interfaces/ui/types";+export { type CategoricalAggregate } from "./features/scores/interfaces/ui/types";+export { type NumericAggregate } from "./features/scores/interfaces/ui/types";+export { type AggregatedScoreData } from "./features/scores/interfaces/ui/types";+export { type ScoreAggregate } from "./features/scores/interfaces/ui/types";+export { type ScoreSimplified } from "./features/scores/interfaces/ui/types";+export { type LastUserScore } from "./features/scores/interfaces/ui/types";// score configs-export * from "./features/scoreConfigs";+export { filterAndValidateDbScoreConfigList } from "./features/scoreConfigs/validation";+export { validateDbScoreConfig } from "./features/scoreConfigs/validation";+export { validateDbScoreConfigSafe } from "./features/scoreConfigs/validation";// commentsexport * from "./features/comments/types";@@ -89,7 +165,17 @@ export * from "./features/experiments/utils";export * from "./features/datasets/validation";// model pricing-export * from "./features/model-pricing/";+export { validateRegexPattern } from "./features/model-pricing/validation";+export { PricingTierUsageConditionSchema } from "./features/model-pricing/validation";+export { PricingTierAttributeConditionSchema } from "./features/model-pricing/validation";+export { PricingTierConditionSchema } from "./features/model-pricing/validation";+export { type PricingTierCondition } from "./features/model-pricing/validation";+export { PricingTierInputSchema } from "./features/model-pricing/validation";+export { type PricingTierInput } from "./features/model-pricing/validation";+export { duplicateNameIndexes } from "./features/model-pricing/validation";+export { tiersMissingConditions } from "./features/model-pricing/validation";+export { validatePricingTiers } from "./features/model-pricing/validation";+export { validatePricingMethod } from "./features/model-pricing/validation";// promptsexport * from "./features/prompts/parsePromptDependencyTags";@@ -121,7 +207,21 @@ export * from "./server/repositories/types";export * from "./server/utils/metadata_conversion";// errors-export * from "./errors/index";+export { BaseError } from "./errors/BaseError";+export { isBaseError } from "./errors/BaseError";+export { LangfuseNotFoundError } from "./errors/NotFoundError";+export { InvalidRequestError } from "./errors/InvalidRequestError";+export { UnauthorizedError } from "./errors/UnauthorizedError";+export { ForbiddenError } from "./errors/ForbiddenError";+export { MethodNotAllowedError } from "./errors/MethodNotAllowedError";+export { ApiError } from "./errors/ApiError";+export { InternalServerError } from "./errors/InternalServerError";+export { LangfuseConflictError } from "./errors/ConflictError";+export { ServiceUnavailableError } from "./errors/ServiceUnavailableError";+export { NotImplementedError } from "./errors/NotImplementedError";+export { PayloadTooLargeError } from "./errors/PayloadTooLargeError";+export { RESOURCE_LIMIT_ERROR_MESSAGE } from "./errors/errorMessages";+export { SLOW_QUERY_HINT_TEXT } from "./errors/errorMessages";export * from "./utils/environment";export * from "./interfaces/search";@@ -131,10 +231,187 @@ export {} from "./server/ingestion/ingestionAttribution";// domain-export * from "./domain";+export { OBSERVATION_FIELD_GROUPS_PUBLIC_API } from "./domain/observation-field-groups";+export { type ObservationFieldGroupPublicApi } from "./domain/observation-field-groups";+export { OBSERVATION_FIELD_GROUPS_FULL } from "./domain/observation-field-groups";+export { type ObservationFieldGroupFull } from "./domain/observation-field-groups";+export { LEGACY_OBSERVATION_EXPORT_FIELDS } from "./domain/observation-field-groups";+export { SCORE_EXPORT_FIELD_GROUPS } from "./domain/export-field-groups";+export { SCORE_EXPORT_CORE_FIELDS } from "./domain/export-field-groups";+export { type ScoreExportFieldGroup } from "./domain/export-field-groups";+export { SCORE_EXPORT_GROUP_FIELDS } from "./domain/export-field-groups";+export { EXPORT_FIELD_GROUPS } from "./domain/export-field-groups";+export { type ExportFieldGroup } from "./domain/export-field-groups";+export { getObservationFieldGroups } from "./domain/export-field-groups";+export { getScoreFieldGroups } from "./domain/export-field-groups";+export { ObservationType } from "./domain/observations";+export { ObservationTypeDomain } from "./domain/observations";+export { ObservationLevel } from "./domain/observations";+export { ObservationLevelDomain } from "./domain/observations";+export { type ObservationLevelType } from "./domain/observations";+export { ObservationDomain } from "./domain/observations";+export { ObservationSchema } from "./domain/observations";+export { type Observation } from "./domain/observations";+export { type ObservationCoreFields } from "./domain/observations";+export { EventsObservationSchema } from "./domain/observations";+export { type EventsObservation } from "./domain/observations";+export { type PartialObservation } from "./domain/observations";+export { type PartialEventsObservation } from "./domain/observations";+export { isGenerationLike } from "./domain/observations";+export { getGenerationLikeTypes } from "./domain/observations";+export { MetadataDomain } from "./domain/traces";+export { TraceDomain } from "./domain/traces";+export { ScoreSourceArray } from "./domain/scores";+export { ScoreSourceEnum } from "./domain/scores";+export { ScoreSourceDomain } from "./domain/scores";+export { type ScoreSourceType } from "./domain/scores";+export { PublicApiCreateScoreSourceDomain } from "./domain/scores";+export { ANNOTATION_SCORE_REQUIRES_CONFIG_ID_MESSAGE } from "./domain/scores";+export { isAnnotationScoreMissingConfigId } from "./domain/scores";+export { CORRECTION_NAME } from "./domain/scores";+export { TEXT_SCORE_MAX_LENGTH } from "./domain/scores";+export { ScoreDataTypeArray } from "./domain/scores";+export { ScoreDataTypeEnum } from "./domain/scores";+export { ScoreDataTypeDomain } from "./domain/scores";+export { type ScoreDataTypeType } from "./domain/scores";+export { NumericData } from "./domain/scores";+export { CategoricalData } from "./domain/scores";+export { BooleanData } from "./domain/scores";+export { TextData } from "./domain/scores";+export { ScoreSchemaExclReferencesAndDates } from "./domain/scores";+export { ScoreSchema } from "./domain/scores";+export { type ScoreDomain } from "./domain/scores";+export { type ScoreByDataType } from "./domain/scores";+export { type ScoresByDataTypes } from "./domain/scores";+export { AGGREGATABLE_SCORE_TYPES } from "./domain/scores";+export { type AggregatableScoreDataType } from "./domain/scores";+export { type AggregatableScore } from "./domain/scores";+export { LISTABLE_SCORE_TYPES } from "./domain/scores";+export { type ListableScoreDataType } from "./domain/scores";+export { type ListableScore } from "./domain/scores";+export { TableViewPresetTableName } from "./domain/table-view-presets";+export { SystemTableViewPresetCategory } from "./domain/table-view-presets";+export { SYSTEM_TABLE_VIEW_PRESET_CATEGORY_META } from "./domain/table-view-presets";+export { SYSTEM_TABLE_VIEW_PRESET_CATEGORIES_ORDERED } from "./domain/table-view-presets";+export { TableViewPresetDomainSchema } from "./domain/table-view-presets";+export { type TableViewPresetDomain } from "./domain/table-view-presets";+export { type TableViewPresetState } from "./domain/table-view-presets";+export { SYSTEM_TABLE_VIEW_PRESET_ID_PREFIX } from "./domain/table-view-presets-catalog";+export { isSystemTableViewPresetId } from "./domain/table-view-presets-catalog";+export { type SystemTableViewPreset } from "./domain/table-view-presets-catalog";+export { getSystemTableViewPresets } from "./domain/table-view-presets-catalog";+export { getSystemTableViewPresetByTableAndId } from "./domain/table-view-presets-catalog";+export { getSystemTableViewPresetById } from "./domain/table-view-presets-catalog";+export { TriggerEventSource } from "./domain/automations";+export { EventActionSchema } from "./domain/automations";+export { type TriggerEventAction } from "./domain/automations";+export { TriggerEventSourceSchema } from "./domain/automations";+export { ProjectNotificationEventTypeSchema } from "./domain/automations";+export { type ProjectNotificationEventType } from "./domain/automations";+export { type TriggerDomain } from "./domain/automations";+export { type AutomationDomain } from "./domain/automations";+export { type ActionDomain } from "./domain/automations";+export { type ActionDomainWithSecrets } from "./domain/automations";+export { ActionTypeSchema } from "./domain/automations";+export { AvailableWebhookApiSchema } from "./domain/automations";+export { RequestHeaderSchema } from "./domain/automations";+export { WebhookActionConfigSchema } from "./domain/automations";+export { SafeWebhookActionConfigSchema } from "./domain/automations";+export { type SafeWebhookActionConfig } from "./domain/automations";+export { WebhookActionCreateSchema } from "./domain/automations";+export { SlackActionConfigSchema } from "./domain/automations";+export { type SlackActionConfig } from "./domain/automations";+export { GitHubDispatchActionConfigSchema } from "./domain/automations";+export { SafeGitHubDispatchActionConfigSchema } from "./domain/automations";+export { type SafeGitHubDispatchActionConfig } from "./domain/automations";+export { GitHubDispatchActionCreateSchema } from "./domain/automations";+export { type GitHubDispatchActionCreate } from "./domain/automations";+export { type GitHubDispatchActionConfigWithSecrets } from "./domain/automations";+export { ActionConfigSchema } from "./domain/automations";+export { ActionCreateSchema } from "./domain/automations";+export { SafeActionConfigSchema } from "./domain/automations";+export { type ActionTypes } from "./domain/automations";+export { type ActionConfig } from "./domain/automations";+export { type ActionCreate } from "./domain/automations";+export { type SafeActionConfig } from "./domain/automations";+export { type WebhookActionCreate } from "./domain/automations";+export { type WebhookActionConfigWithSecrets } from "./domain/automations";+export { type ActionConfigWithSecrets } from "./domain/automations";+export { isWebhookActionConfig } from "./domain/automations";+export { isSlackActionConfig } from "./domain/automations";+export { isWebhookAction } from "./domain/automations";+export { isSafeWebhookActionConfig } from "./domain/automations";+export { convertToSafeWebhookConfig } from "./domain/automations";+export { isGitHubDispatchActionConfig } from "./domain/automations";+export { isGitHubDispatchAction } from "./domain/automations";+export { isSafeGitHubDispatchActionConfig } from "./domain/automations";+export { convertToSafeGitHubDispatchConfig } from "./domain/automations";+export { WebhookContentTypeHeader } from "./domain/webhooks";+export { WebhookSignatureHeader } from "./domain/webhooks";+export { WebhookUserAgentHeader } from "./domain/webhooks";+export { LangfuseUserAgent } from "./domain/webhooks";+export { WebhookDefaultHeaders } from "./domain/webhooks";+export { WebhookProtectedHeaders } from "./domain/webhooks";+export { WebhookOutboundBaseSchema } from "./domain/webhooks";+export { PromptWebhookOutboundSchema } from "./domain/webhooks";+export { type PromptWebhookOutput } from "./domain/webhooks";+export { GitHubDispatchWebhookOutboundSchema } from "./domain/webhooks";+export { type GitHubDispatchWebhookOutput } from "./domain/webhooks";+export { PromptDomainSchema } from "./domain/prompts";+export { type PromptDomain } from "./domain/prompts";+export { datasetItemMediaFields } from "./domain/dataset-items";+export { type DatasetItemMediaField } from "./domain/dataset-items";+export { type DatasetItemDomain } from "./domain/dataset-items";+export { type DatasetItemDomainWithoutIO } from "./domain/dataset-items";+export { MediaContentType } from "./domain/media";+export { MediaFileExtension } from "./domain/media";+export { type MediaField } from "./domain/media";+export { OBSERVATION_FIELD_SIZE_LIMIT_MEDIA_SOURCE } from "./domain/media";+export { isMediaContentType } from "./domain/media";+export { getFileExtensionFromContentType } from "./domain/media";+export { AUDIT_LOG_PARAMS_MAX_BYTES } from "./domain/auditLogs";+export { AUDIT_LOG_TEXT_MAX_BYTES } from "./domain/auditLogs";+export { AUDIT_LOG_RESOURCE_REFS_MAX } from "./domain/auditLogs";+export { AUDIT_LOG_TRUNCATION_MARKER } from "./domain/auditLogs";+export { type AuditLogResourceRefType } from "./domain/auditLogs";+export { type AuditLogResourceRef } from "./domain/auditLogs";+export { toAuditLogResourceRef } from "./domain/auditLogs";+export { type AuditLogActor } from "./domain/auditLogs";+export { type AuditRequestContext } from "./domain/auditLogs";+export { AuditLogStagingPayloadSchema } from "./domain/auditLogs";+export { type AuditLogStagingPayload } from "./domain/auditLogs";+export { AuditLogEventSchema } from "./domain/auditLogs";+export { type AuditLogEvent } from "./domain/auditLogs";// io representation-export * from "./utils/IORepresentation";+export { parseIO } from "./utils/IORepresentation/parseIO";+export { ToolDefinitionSchema } from "./utils/IORepresentation/chatML/types";+export { ToolCallSchema } from "./utils/IORepresentation/chatML/types";+export { ParsedMediaReferenceSchema } from "./utils/IORepresentation/chatML/types";+export { type ParsedMediaReferenceType } from "./utils/IORepresentation/chatML/types";+export { MEDIA_REFERENCE_PATTERN } from "./utils/IORepresentation/chatML/types";+export { MediaReferenceStringSchema } from "./utils/IORepresentation/chatML/types";+export { ThinkingContentPartSchema } from "./utils/IORepresentation/chatML/types";+export { type ThinkingContentPart } from "./utils/IORepresentation/chatML/types";+export { RedactedThinkingContentPartSchema } from "./utils/IORepresentation/chatML/types";+export { type RedactedThinkingContentPart } from "./utils/IORepresentation/chatML/types";+export { type OpenAITextContentPartType } from "./utils/IORepresentation/chatML/types";+export { OpenAIUrlImageUrl } from "./utils/IORepresentation/chatML/types";+export { type OpenAIImageContentPartType } from "./utils/IORepresentation/chatML/types";+export { MediaReferencePartSchema } from "./utils/IORepresentation/chatML/types";+export { AiSdkFileContentPartSchema } from "./utils/IORepresentation/chatML/types";+export { type AiSdkFileContentPart } from "./utils/IORepresentation/chatML/types";+export { isAiSdkFileContentPart } from "./utils/IORepresentation/chatML/types";+export { OpenAIContentParts } from "./utils/IORepresentation/chatML/types";+export { isMediaReferencePart } from "./utils/IORepresentation/chatML/types";+export { type OpenAIOutputAudioType } from "./utils/IORepresentation/chatML/types";+export { OpenAIContentSchema } from "./utils/IORepresentation/chatML/types";+export { isOpenAITextContentPart } from "./utils/IORepresentation/chatML/types";+export { isOpenAIImageContentPart } from "./utils/IORepresentation/chatML/types";+export { BaseChatMlMessageSchema } from "./utils/IORepresentation/chatML/types";+export { SimpleChatMlArraySchema } from "./utils/IORepresentation/chatML/types";+export { ChatMlMessageSchema } from "./utils/IORepresentation/chatML/types";+export { ChatMlArraySchema } from "./utils/IORepresentation/chatML/types";export * from "./utils/mediaReferences";export * from "./utils/s3Uri";@@ -150,3 +427,19 @@ export {export * from "./features/query/types";export * from "./features/query/dataModel";export * from "./features/query/validateQuery";++export { TooManyRequestsError } from "./errors/TooManyRequestsError";+export { BadGatewayError } from "./errors/BadGatewayError";+export { GatewayTimeoutError } from "./errors/GatewayTimeoutError";+export { toBaseError } from "./errors/toBaseError";+export { TRACE_EXPORT_FIELD_GROUPS } from "./domain/export-field-groups";+export type { TraceExportFieldGroup } from "./domain/export-field-groups";+export { TRACE_EXPORT_FIELDS } from "./domain/export-field-groups";+export { hasTraceFieldGroups } from "./domain/export-field-groups";+export { getTraceFieldGroups } from "./domain/export-field-groups";+export { PagerDutyActionConfigSchema } from "./domain/automations";+export { SafePagerDutyActionConfigSchema } from "./domain/automations";+export { PagerDutyActionCreateSchema } from "./domain/automations";+export type { PagerDutyActionConfigWithSecrets } from "./domain/automations";+export type { SafePagerDutyActionConfig } from "./domain/automations";+export { isPagerDutyActionConfig } from "./domain/automations";diff --git a/packages/shared/src/observationsTable.ts b/packages/shared/src/observationsTable.tsindex 17cca64a7e..64ff7dfcca 100644--- a/packages/shared/src/observationsTable.ts+++ b/packages/shared/src/observationsTable.ts@@ -1,9 +1,10 @@-import { ObservationLevelType } from "./domain";+import { ObservationLevelType } from "./domain/observations";import {type SingleValueOption,type ColumnDefinition,MultiValueOption,-} from "./tableDefinitions";+} from "./tableDefinitions/types";+import { formatColumnOptions } from "./tableDefinitions/typeHelpers";// to be used server sidediff --git a/packages/shared/src/server/auth/apiKeys.test.ts b/packages/shared/src/server/auth/apiKeys.test.tsindex 08213f8d6d..4f5a241980 100644--- a/packages/shared/src/server/auth/apiKeys.test.ts+++ b/packages/shared/src/server/auth/apiKeys.test.ts@@ -1,6 +1,6 @@import { describe, expect, it, vi } from "vitest";import { type Prisma } from "@prisma/client";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";// Give createApiKey a SALT without depending on the ambient env.vi.mock("../../env", () => ({ env: { SALT: "test-salt" } }));diff --git a/packages/shared/src/server/auth/apiKeys.ts b/packages/shared/src/server/auth/apiKeys.tsindex 725480ec30..d02dea8b4b 100644--- a/packages/shared/src/server/auth/apiKeys.ts+++ b/packages/shared/src/server/auth/apiKeys.ts@@ -4,7 +4,7 @@ import { randomUUID } from "crypto";import * as crypto from "crypto";import type { Cluster, Redis } from "ioredis";import { env } from "../../env";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import {ApiKeyId,hasApiKeyKind,diff --git a/packages/shared/src/server/auth/credentials/index.ts b/packages/shared/src/server/auth/credentials/index.tsdeleted file mode 100644index 3e1aa2cdb8..0000000000--- a/packages/shared/src/server/auth/credentials/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./types";-export * from "./RefreshingTokenManager";diff --git a/packages/shared/src/server/cache/index.ts b/packages/shared/src/server/cache/index.tsdeleted file mode 100644index 9855312d9d..0000000000--- a/packages/shared/src/server/cache/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./localCache";diff --git a/packages/shared/src/server/clickhouse/queryTracking.test.ts b/packages/shared/src/server/clickhouse/queryTracking.test.tsindex 1185d29ffd..3d2c9492a3 100644--- a/packages/shared/src/server/clickhouse/queryTracking.test.ts+++ b/packages/shared/src/server/clickhouse/queryTracking.test.ts@@ -8,7 +8,7 @@ const mocks = vi.hoisted(() => ({}));vi.mock("../../env", () => ({ env: mocks.env }));-vi.mock("../repositories", () => ({ queryClickhouse: vi.fn() }));+vi.mock("../repositories/clickhouse", () => ({ queryClickhouse: vi.fn() }));import { systemTableRef } from "./queryTracking";diff --git a/packages/shared/src/server/clickhouse/queryTracking.ts b/packages/shared/src/server/clickhouse/queryTracking.tsindex 4052d82862..d72a6f3030 100644--- a/packages/shared/src/server/clickhouse/queryTracking.ts+++ b/packages/shared/src/server/clickhouse/queryTracking.ts@@ -1,5 +1,5 @@import { env } from "../../env";-import { queryClickhouse } from "../repositories";+import { queryClickhouse } from "../repositories/clickhouse";import { quoteClickhouseString } from "./clickhouseIdentifiers";// ============================================================================diff --git a/packages/shared/src/server/clickhouse/schemaUtils.ts b/packages/shared/src/server/clickhouse/schemaUtils.tsindex 82e5b1f0f0..aefd23cb72 100644--- a/packages/shared/src/server/clickhouse/schemaUtils.ts+++ b/packages/shared/src/server/clickhouse/schemaUtils.ts@@ -1,4 +1,4 @@-import { LangfuseNotFoundError } from "../../errors";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";import { eventTypes } from "../ingestion/types";import { ClickhouseTableName, ClickhouseTableNames } from "./schema";diff --git a/packages/shared/src/server/datasets/schemaValidation.ts b/packages/shared/src/server/datasets/schemaValidation.tsindex c0cb71e0b6..83a4260e47 100644--- a/packages/shared/src/server/datasets/schemaValidation.ts+++ b/packages/shared/src/server/datasets/schemaValidation.ts@@ -1,4 +1,7 @@-import { createDatasetItemFilterState, getDatasetItems } from "../repositories";+import {+ createDatasetItemFilterState,+ getDatasetItems,+} from "../repositories/dataset-items";import { DatasetSchemaValidator } from "../services/DatasetService/DatasetSchemaValidator";import type { DatasetSchemaValidationError } from "./schemaTypes";diff --git a/packages/shared/src/server/filterToPrisma.test.ts b/packages/shared/src/server/filterToPrisma.test.tsindex fcafc124de..998e624d61 100644--- a/packages/shared/src/server/filterToPrisma.test.ts+++ b/packages/shared/src/server/filterToPrisma.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";-import { type ColumnDefinition } from "../tableDefinitions";+import type { ColumnDefinition } from "../tableDefinitions/types";import { type FilterState } from "../types";import { tableColumnsToSqlFilter } from "./filterToPrisma";diff --git a/packages/shared/src/server/filterToPrisma.ts b/packages/shared/src/server/filterToPrisma.tsindex c22c0a8d6f..2aacc66441 100644--- a/packages/shared/src/server/filterToPrisma.ts+++ b/packages/shared/src/server/filterToPrisma.ts@@ -1,11 +1,12 @@/* eslint-disable @typescript-eslint/no-use-before-define */import { Prisma } from "@prisma/client";-import { ColumnDefinition, type TableNames } from "../tableDefinitions";+import { ColumnDefinition, type TableNames } from "../tableDefinitions/types";+import { FilterState } from "../types";import { filterOperators, timeFilter } from "../interfaces/filters";import { z } from "zod";import { logger } from "./index";-import { InvalidRequestError } from "../errors";+import { InvalidRequestError } from "../errors/InvalidRequestError";import { escapeSqlLikePattern } from "./utils/sqlLike";const operatorReplacements = {diff --git a/packages/shared/src/server/index.ts b/packages/shared/src/server/index.tsindex 457c679e18..2b132e0d11 100644--- a/packages/shared/src/server/index.ts+++ b/packages/shared/src/server/index.ts@@ -5,10 +5,27 @@ import {} from "./repositories/events";export * from "./services/StorageService";-export * from "./media";+export { type MediaPayloadKind } from "./media/MediaPayloadProcessor";+export { type MediaInvalidReason } from "./media/MediaPayloadProcessor";+export { type MediaIgnoredReason } from "./media/MediaPayloadProcessor";+export { type MediaPayloadCandidate } from "./media/MediaPayloadProcessor";+export { type MediaDetectionPath } from "./media/MediaPayloadProcessor";+export { type TransformMediaPayloadResult } from "./media/MediaPayloadProcessor";+export { transformMediaPayload } from "./media/MediaPayloadProcessor";+export { getMediaId } from "./media/mediaService";+export { getMediaBucketPath } from "./media/mediaService";+export { upsertMediaRecord } from "./media/mediaService";+export { linkMediaToTraceOrObservation } from "./media/mediaService";+export { type UploadMediaForTraceResult } from "./media/mediaService";+export { uploadMediaForTrace } from "./media/mediaService";+export { otelMediaUploads } from "./media/otelMediaUploads";+export { forEachMedia } from "./media/otelMediaUploads";+export { mediaDispatchConcurrency } from "./media/otelMediaUploads";export * from "./services/safeBlobKeySegment";export * from "./ingestion/eventBucketPath";-export * from "./cache";+export { type LocalCacheLoadResult } from "./cache/localCache";+export { type LocalCacheConfig } from "./cache/localCache";+export { LocalCache } from "./cache/localCache";export * from "./services/BufferedStreamUploader";export * from "./services/S3ChunkedUploadStrategy";export * from "./services/email/transport";@@ -28,9 +45,14 @@ export * from "./services/PromptService/types";export * from "./services/traces-ui-table-service";export * from "./services/InMemoryFilterService";export * from "./automations";-export * from "./services/DatasetService";+export { DatasetItemValidator } from "./services/DatasetService/DatasetItemValidator";+export { DatasetSchemaValidator } from "./services/DatasetService/DatasetSchemaValidator";export * from "./services/commentFilterService";-export * from "./services/LLMApiKeys";+export { findProjectLlmApiKeyCandidates } from "./services/LLMApiKeys/LlmApiKeyRepository";+export { type EffectiveLlmApiKey } from "./services/LLMApiKeys/LlmApiKeyService";+export { resolveLlmApiKey } from "./services/LLMApiKeys/LlmApiKeyService";+export { listEffectiveLlmApiKeys } from "./services/LLMApiKeys/LlmApiKeyService";+export { findCompatibleLlmApiKeysForProjects } from "./services/LLMApiKeys/findCompatibleLlmApiKeysForProjects";export * from "./datasets/schemaValidation";export * from "./datasets/schemaTypes";export * from "./evalJobConfigCache";@@ -48,7 +70,10 @@ export * from "./llm/typesafe/typeSafeDecisionModelClient";export * from "./utils/traceId";export * from "./auth/apiKeyCache";export * from "./auth/apiKeys";-export * from "./auth/credentials";+export { type ManagedAccessToken } from "./auth/credentials/types";+export { type ManagedCredentialProvider } from "./auth/credentials/types";+export { type RefreshingTokenManagerOptions } from "./auth/credentials/RefreshingTokenManager";+export { RefreshingTokenManager } from "./auth/credentials/RefreshingTokenManager";export * from "./auth/invalidateApiKeys";export * from "./auth/customSsoProvider";export * from "./auth/gitHubEnterpriseProvider";@@ -71,7 +96,31 @@ export * from "./llm/baseUrlValidation";export * from "./llm/ai-sdk/providers/bedrock";export * from "./llm/ai-sdk/providers/vertex";export * from "./llm/ai-sdk/providers/vertexAuth";-export * from "./outbound-url";+export { type RequestInitWithDispatcher } from "./outbound-url/connection";+export { type OutboundUrlConnectionValidationOptions } from "./outbound-url/connection";+export { addSecureOutboundConnectionValidation } from "./outbound-url/connection";+export { getOutboundProxyDispatcher } from "./outbound-url/connection";+export { createSecureOutboundLookup } from "./outbound-url/connection";+export { getSecureOutboundHttpAgents } from "./outbound-url/connection";+export { redactUrlCredentials } from "./outbound-url/fetch";+export { urlForLog } from "./outbound-url/fetch";+export { RedirectValidationError } from "./outbound-url/fetch";+export { MaxRedirectsExceededError } from "./outbound-url/fetch";+export { CircularRedirectError } from "./outbound-url/fetch";+export { type RedirectResult } from "./outbound-url/fetch";+export { type RedirectUrlValidator } from "./outbound-url/fetch";+export { type RedirectOptions } from "./outbound-url/fetch";+export { fetchWithSecureRedirects } from "./outbound-url/fetch";+export { shouldBypassProxy } from "./outbound-url/noProxy";+export { type OutboundUrlValidationErrorCode } from "./outbound-url/validation";+export { OutboundUrlValidationError } from "./outbound-url/validation";+export { DNS_LOOKUP_FAILED_MESSAGE_PREFIX } from "./outbound-url/validation";+export { type OutboundUrlValidationWhitelist } from "./outbound-url/validation";+export { type ValidateOutboundUrlHostOptions } from "./outbound-url/validation";+export { resolveHost } from "./outbound-url/validation";+export { parseOutboundUrl } from "./outbound-url/validation";+export { validateOutboundUrlHost } from "./outbound-url/validation";+export { validateOutboundResolvedIp } from "./outbound-url/validation";export * from "./services/blobStorageEndpointValidation";export * from "./services/externalMediaStorageEndpointValidation/externalMediaStorageEndpointValidation";export * from "./llm/getInternalTracingHandler";@@ -99,11 +148,42 @@ export * from "./ingestion/ingestionAttribution";export * from "./ingestion/processEventBatch";export * from "../server/ingestion/validateAndInflateScore";export * from "./ingestion/extractToolsBackend";-export * from "./normalized-io";-export * from "./transcript";-export * from "./traceBatch";+export { type OtelSpan } from "./normalized-io/parser";+export { type OtelScope } from "./normalized-io/parser";+export { type OtelSpanContext } from "./normalized-io/parser";+export { type NormalizeIOSource } from "./normalized-io/parser";+export { normalizeIO } from "./normalized-io/parser";+export { type NormalizedEvalRecord } from "./normalized-io/projections/eval-record";+export { toEvalRecord } from "./normalized-io/projections/eval-record";+export { toToolColumns } from "./normalized-io/projections/tool-call-columns";+export { orderObservations } from "./transcript/ordering";+export { assembleTranscript } from "./transcript/transcript";+export { renderTranscript } from "./transcript/topics-renderer";+export { renderTranscriptFromObservations } from "./transcript/topics-renderer";+export { transcriptBlockTypes } from "./transcript/topics-renderer";+export { renderGenericTranscript } from "./transcript/generic-renderer";+export { topicsTranscriptConfig } from "./transcript/topics-renderer-config";+export { transcriptRenderConfigSchema } from "./transcript/topics-renderer-config";+export { type TranscriptRenderConfig } from "./transcript/topics-renderer-config";+export { type TranscriptBlockType } from "./transcript/topics-renderer";+export { type TranscriptOptions } from "./transcript/types";+export { type TranscriptObservation } from "./transcript/types";+export { type ThreadMessage } from "./transcript/types";+export { type Turn } from "./transcript/types";+export { type Thread } from "./transcript/types";+export { type Transcript } from "./transcript/types";+export { createTraceBatchInputStorage } from "./traceBatch/storage";+export { TRACE_BATCH_INPUT_MAX_CHARACTERS } from "./traceBatch/storage";+export { UnsupportedTraceBatchInputVersionError } from "./traceBatch/storage";+export { type TraceBatchInputReference } from "./traceBatch/storage";+export { type TraceBatchInputData } from "./traceBatch/storage";+export { type TraceBatchInputStorage } from "./traceBatch/storage";export * from "../server/queries/public-api-filter-builder";-export * from "../server/pricing-tiers";+export { type PricingTierMatchAttributes } from "./pricing-tiers/types";+export { type PricingTierMatchResult } from "./pricing-tiers/types";+export { type PricingTierWithPrices } from "./pricing-tiers/types";+export { hasPricingTierUsageDetails } from "./pricing-tiers/matcher";+export { matchPricingTier } from "./pricing-tiers/matcher";export * from "./redis/redis";export * from "./redis/traceUpsert";export * from "./redis/createEvalQueue";@@ -148,7 +228,16 @@ export * from "./redis/s3SlowdownTracking";export * from "./redis/ingestionFailureTracking";export * from "./auth/types";export * from "./queues";-export * from "./notifications";+export { ProjectNotificationEventTypeSchema } from "./notifications/types";+export { type ProjectNotificationEventType } from "./notifications/types";+export { ProjectNotificationSeveritySchema } from "./notifications/types";+export { type ProjectNotificationSeverity } from "./notifications/types";+export { ProjectNotificationEventSchema } from "./notifications/types";+export { type ProjectNotificationEvent } from "./notifications/types";+export { ProjectNotificationWebhookQueueEventSchema } from "./notifications/types";+export { type ProjectNotificationWebhookQueueEvent } from "./notifications/types";+export { buildProjectNotificationSlackMessage } from "./notifications/buildProjectNotificationSlackMessage";+export { dispatchProjectNotification } from "./notifications/dispatchProjectNotification";export * from "./orderByToPrisma";export * from "./filterToPrisma";export * from "./prismaFilter";@@ -156,13 +245,470 @@ export * from "./instrumentation";export * from "./logger";export * from "./processErrorHandlers";export * from "./headerPropagation";-export * from "./queries";+export { type FullObservations } from "./queries/createGenerationsQuery";+export { type FullObservationsWithScores } from "./queries/createGenerationsQuery";+export { type FullEventsObservation } from "./queries/createGenerationsQuery";+export { type FullEventsObservations } from "./queries/createGenerationsQuery";+export { type ObservationPriceFields } from "./queries/createGenerationsQuery";+export { type Filter } from "./queries/clickhouse-sql/clickhouse-filter";+export { FilterList } from "./queries/clickhouse-sql/clickhouse-filter";+export { StringFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { DateTimeFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { StringOptionsFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { CategoryOptionsFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { NumberFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { ArrayOptionsFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { BooleanFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { NumberObjectFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { StringObjectFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { NullFilter } from "./queries/clickhouse-sql/clickhouse-filter";+export { encodeBooleanScoreEntry } from "./queries/clickhouse-sql/clickhouse-filter";+export { filtersRequireEventsFull } from "./queries/clickhouse-sql/clickhouse-filter";+export { metadataFilterCanPruneEventsFull } from "./queries/clickhouse-sql/clickhouse-filter";+export { type ClickhouseOperator } from "./queries/clickhouse-sql/clickhouse-filter";+export { metadataFilterIsEventsCoreSafe } from "./queries/clickhouse-sql/events-core-truncation";+export { orderByToClickhouseSql } from "./queries/clickhouse-sql/orderby-factory";+export { orderByToEntries } from "./queries/clickhouse-sql/orderby-factory";+export { createFilterFromFilterState } from "./queries/clickhouse-sql/factory";+export { clickhouseSearchCondition } from "./queries/clickhouse-sql/search";+export { type ClickhouseSearchConditionOptions } from "./queries/clickhouse-sql/search";+export { FTS_EVENTS_TABLES } from "./queries/clickhouse-sql/fts";+export { FTS_MATCH_OPERATOR } from "./queries/clickhouse-sql/fts";+export { FTS_METADATA_FIELD } from "./queries/clickhouse-sql/fts";+export { FTS_TEXT_FIELDS } from "./queries/clickhouse-sql/fts";+export { FTS_TEXT_OPERATORS } from "./queries/clickhouse-sql/fts";+export { bareFtsField } from "./queries/clickhouse-sql/fts";+export { hasFtsSearchToken } from "./queries/clickhouse-sql/fts";+export { isFtsAcceleratedIoOperator } from "./queries/clickhouse-sql/fts";+export { isFtsEventsTable } from "./queries/clickhouse-sql/fts";+export { isFtsMatchOperator } from "./queries/clickhouse-sql/fts";+export { isFtsMetadataField } from "./queries/clickhouse-sql/fts";+export { isFtsMetadataTarget } from "./queries/clickhouse-sql/fts";+export { isFtsTextField } from "./queries/clickhouse-sql/fts";+export { isFtsTextTarget } from "./queries/clickhouse-sql/fts";+export { postgresSearchCondition } from "./queries/postgres-sql/search";+export { convertApiProvidedFilterToClickhouseFilter } from "./queries/public-api-filter-builder";+export { createPublicApiObservationsColumnMapping } from "./queries/public-api-filter-builder";+export { createPublicApiTracesColumnMapping } from "./queries/public-api-filter-builder";+export { deriveFilters } from "./queries/public-api-filter-builder";+export { type ApiColumnMapping } from "./queries/public-api-filter-builder";+export { ALL_SESSION_EVENTS_FIELDS } from "./queries/clickhouse-sql/event-query-builder";+export { CTEQueryBuilder } from "./queries/clickhouse-sql/event-query-builder";+export { EventsAggQueryBuilder } from "./queries/clickhouse-sql/event-query-builder";+export { EventsAggregationQueryBuilder } from "./queries/clickhouse-sql/event-query-builder";+export { EventsSessionAggregationQueryBuilder } from "./queries/clickhouse-sql/event-query-builder";+export { EventsQueryBuilder } from "./queries/clickhouse-sql/event-query-builder";+export { ExperimentsAggregationQueryBuilder } from "./queries/clickhouse-sql/event-query-builder";+export { buildEventsFullTableSplitQuery } from "./queries/clickhouse-sql/event-query-builder";+export { normalizeSessionCounts } from "./queries/clickhouse-sql/event-query-builder";+export { type CTESchema } from "./queries/clickhouse-sql/event-query-builder";+export { type CTEWithSchema } from "./queries/clickhouse-sql/event-query-builder";+export { type QueryWithParams } from "./queries/clickhouse-sql/event-query-builder";+export { type ExperimentsAggregationFieldSetName } from "./queries/clickhouse-sql/event-query-builder";+export { type SessionEventsFields } from "./queries/clickhouse-sql/event-query-builder";+export { type SplitQueryBuilder } from "./queries/clickhouse-sql/event-query-builder";+export { OBSERVATION_FIELD_GROUP_FIELD_NAMES } from "./repositories/events-field-sets";+export { type SessionEventsField } from "./repositories/events-selects";+export { type SessionEventsMetricsRow } from "./repositories/events-selects";+export { buildEventsFilterOptionColumnQuery } from "./queries/clickhouse-sql/event-filter-options";+export { buildEventsFilterOptionsForColumnsQuery } from "./queries/clickhouse-sql/event-filter-options";+export { buildEventsExactFilterOptionsForColumnsQuery } from "./queries/clickhouse-sql/event-filter-options";+export { buildEventsMetadataValuesQuery } from "./queries/clickhouse-sql/event-filter-options";+export { EVENTS_FILTER_OPTION_TOP_N } from "./queries/clickhouse-sql/event-filter-options";+export { EVENTS_APPROX_TOTAL_COUNT_MARKER } from "./queries/clickhouse-sql/event-filter-options";+export { normalizeEventFilterOptionColumn } from "./queries/clickhouse-sql/event-filter-options";+export { type EventFilterOptionRow } from "./queries/clickhouse-sql/event-filter-options";+export { type EventFilterOptionColumn } from "./queries/clickhouse-sql/event-filter-options";+export { type EventFilterOptionScope } from "./queries/clickhouse-sql/event-filter-options";+export { eventsScoresAggregation } from "./queries/clickhouse-sql/query-fragments";+export { eventsSessionsAggregation } from "./queries/clickhouse-sql/query-fragments";+export { eventsSessionScoresAggregation } from "./queries/clickhouse-sql/query-fragments";+export { eventsTraceMetadata } from "./queries/clickhouse-sql/query-fragments";+export { eventsTracesAggregation } from "./queries/clickhouse-sql/query-fragments";+export { eventsTracesScoresAggregation } from "./queries/clickhouse-sql/query-fragments";+export { scoreBooleansAggregation } from "./queries/clickhouse-sql/query-fragments";+export { buildEventsBlobExportStreamQuery } from "./queries/clickhouse-sql/events-stream-query";+export { buildEventsStreamQuery } from "./queries/clickhouse-sql/events-stream-query";+export { type EventsStreamQuery } from "./queries/clickhouse-sql/events-stream-query";+export { type EventsStreamQueryInput } from "./queries/clickhouse-sql/events-stream-query";+export { buildEventsObservationRowSelection } from "./queries/clickhouse-sql/events-observation-row-selection";+export { eventSearchCondition } from "./queries/clickhouse-sql/events-observation-row-selection";+export { groupEventsObservationFilters } from "./queries/clickhouse-sql/events-observation-row-selection";+export { toLevelAgnosticScoreFilter } from "./queries/clickhouse-sql/events-observation-row-selection";+export { type EventsObservationFilterGroups } from "./queries/clickhouse-sql/events-observation-row-selection";+export { type EventsObservationRowSelectionInput } from "./queries/clickhouse-sql/events-observation-row-selection";+export { extractTimeFilter } from "./queries/clickhouse-sql/filter-utils";+export { isSeekEligibleFilter } from "./queries/clickhouse-sql/score-seek-eligibility";+export { scoreOnlyFiltersAreSeekEligible } from "./queries/clickhouse-sql/score-seek-eligibility";export * from "./queries/clickhouse-sql/orderby-factory";export * from "./queries/clickhouse-sql/query-options";-export * from "./repositories";-export * from "./billing/billingLedgerShadow";-export { SCORE_TO_TRACE_OBSERVATIONS_INTERVAL } from "./repositories/constants";+export { searchExistingAnnotationScore } from "./repositories/scores";+export { getScoreById } from "./repositories/scores";+export { getScoresByIds } from "./repositories/scores";+export { upsertScore } from "./repositories/scores";+export { type GetScoresForTracesProps } from "./repositories/scores";+export { getScoresForSessions } from "./repositories/scores";+export { getScoresForExperiments } from "./repositories/scores";+export { getTraceScoresForDatasetRuns } from "./repositories/scores";+export { getScoresForExperimentItems } from "./repositories/scores";+export { getScoresForTraces } from "./repositories/scores";+export { getScoresAndCorrectionsForTraces } from "./repositories/scores";+export { type GetScoresForObservationsProps } from "./repositories/scores";+export { getScoresForObservations } from "./repositories/scores";+export { queryScoreRecordsForExperimentItems } from "./repositories/scores";+export { queryScoreRecordsForExperiments } from "./repositories/scores";+export { getScoresGroupedByNameSourceType } from "./repositories/scores";+export { getNumericScoresGroupedByName } from "./repositories/scores";+export { getBooleanScoresGroupedByName } from "./repositories/scores";+export { getCategoricalScoresGroupedByName } from "./repositories/scores";+export { getScoresUiCount } from "./repositories/scores";+export { type ScoreUiTableRow } from "./repositories/scores";+export { getScoresUiTable } from "./repositories/scores";+export { getScoresUiCountFromEvents } from "./repositories/scores";+export { type ScoreUiTableRowFromEvents } from "./repositories/scores";+export { getScoresUiTableFromEvents } from "./repositories/scores";+export { getScoreNames } from "./repositories/scores";+export { getScoreStringValues } from "./repositories/scores";+export { deleteScores } from "./repositories/scores";+export { deleteScoresByTraceIds } from "./repositories/scores";+export { deleteScoresByProjectId } from "./repositories/scores";+export { hasAnyScoreOlderThan } from "./repositories/scores";+export { deleteScoresOlderThanDays } from "./repositories/scores";+export { getNumericScoreHistogram } from "./repositories/scores";+export { getAggregatedScoresForPrompts } from "./repositories/scores";+export { buildAggregatedScoresForPromptsFromEventsQuery } from "./repositories/scores";+export { getAggregatedScoresForPromptsFromEvents } from "./repositories/scores";+export { getScoreCountsByProjectInCreationInterval } from "./repositories/scores";+export { getScoreCountOfProjectsSinceCreationDate } from "./repositories/scores";+export { getDistinctScoreNames } from "./repositories/scores";+export { getScoresForBlobStorageExport } from "./repositories/scores";+export { getScoresForBlobStorageExportParquet } from "./repositories/scores";+export { getScoresForAnalyticsIntegrations } from "./repositories/scores";+export { hasAnyScore } from "./repositories/scores";+export { getScoreMetadataById } from "./repositories/scores";+export { getScoreCountsByProjectAndDay } from "./repositories/scores";+export { ScoresCursorV3 } from "./repositories/scores";+export { type ScoresCursorV3Type } from "./repositories/scores";+export { EncodedScoresCursorV3 } from "./repositories/scores";+export { encodeCursorV3 } from "./repositories/scores";+export { type ScoreQueryType } from "./repositories/scores";+export { _handleGenerateScoresForPublicApi } from "./repositories/scores";+export { _handleGetScoresCountForPublicApi } from "./repositories/scores";+export { buildSelectColumns } from "./repositories/scores";+export { transformBooleanValueForFilter } from "./repositories/scores";+export { polymorphicValueForV3 } from "./repositories/scores";export { scoreDomainToV3 } from "./repositories/scores";+export { listScoresV3ForPublicApi } from "./repositories/scores";+export { checkTraceExistsAndGetTimestamp } from "./repositories/traces";+export { upsertTrace } from "./repositories/traces";+export { getTracesByIds } from "./repositories/traces";+export { getTracesBySessionId } from "./repositories/traces";+export { readProjectHasTracesFlag } from "./repositories/traces";+export { persistProjectHasTracesFlag } from "./repositories/traces";+export { hasAnyTrace } from "./repositories/traces";+export { getTraceCountsByProjectInCreationInterval } from "./repositories/traces";+export { getLastTraceTimestampsByProjectsFromTracesTable } from "./repositories/traces";+export { getTraceCountOfProjectsSinceCreationDate } from "./repositories/traces";+export { getTraceByIdFromTracesTable } from "./repositories/traces";+export { getTracesGroupedByName } from "./repositories/traces";+export { getTracesGroupedBySessionId } from "./repositories/traces";+export { getTracesGroupedByUsers } from "./repositories/traces";+export { type GroupedTracesQueryProp } from "./repositories/traces";+export { getTracesGroupedByTags } from "./repositories/traces";+export { getTracesIdentifierForSessionFromTracesTable } from "./repositories/traces";+export { deleteTraces } from "./repositories/traces";+export { hasAnyTraceOlderThan } from "./repositories/traces";+export { deleteTracesOlderThanDays } from "./repositories/traces";+export { deleteTracesByProjectId } from "./repositories/traces";+export { hasAnyUser } from "./repositories/traces";+export { getTotalUserCount } from "./repositories/traces";+export { getUserMetrics } from "./repositories/traces";+export { getTracesForBlobStorageExport } from "./repositories/traces";+export { getTracesForBlobStorageExportParquet } from "./repositories/traces";+export { getTracesForAnalyticsIntegrations } from "./repositories/traces";+export { getTracesByIdsForAnyProject } from "./repositories/traces";+export { getAgentGraphData } from "./repositories/traces";+export { getTraceCountsByProjectAndDay } from "./repositories/traces";+export { TRACE_FIELD_GROUPS } from "./repositories/traces";+export { type TraceFieldGroup } from "./repositories/traces";+export { type TraceQueryType } from "./repositories/traces";+export { generateTracesForPublicApi } from "./repositories/traces";+export { getTracesCountForPublicApi } from "./repositories/traces";+export { checkObservationExists } from "./repositories/observations";+export { upsertObservation } from "./repositories/observations";+export { type GetObservationsForTraceOpts } from "./repositories/observations";+export { getObservationsForTrace } from "./repositories/observations";+export { getObservationForTraceIdByName } from "./repositories/observations";+export { getObservationByIdFromObservationsTable } from "./repositories/observations";+export { getObservationsById } from "./repositories/observations";+export { type ObservationTableQuery } from "./repositories/observations";+export { type ObservationsTableQueryResult } from "./repositories/observations";+export { getObservationsTableCount } from "./repositories/observations";+export { getObservationsTableWithModelData } from "./repositories/observations";+export { getObservationsGroupedByModel } from "./repositories/observations";+export { getObservationsGroupedByModelId } from "./repositories/observations";+export { getObservationsGroupedByName } from "./repositories/observations";+export { getObservationsGroupedByToolName } from "./repositories/observations";+export { getObservationsGroupedByCalledToolName } from "./repositories/observations";+export { getObservationsGroupedByPromptName } from "./repositories/observations";+export { getCostForTraces } from "./repositories/observations";+export { deleteObservationsByTraceIds } from "./repositories/observations";+export { hasAnyObservation } from "./repositories/observations";+export { deleteObservationsByProjectId } from "./repositories/observations";+export { hasAnyObservationOlderThan } from "./repositories/observations";+export { deleteObservationsOlderThanDays } from "./repositories/observations";+export { getObservationsWithPromptName } from "./repositories/observations";+export { getObservationMetricsForPrompts } from "./repositories/observations";+export { getLatencyAndTotalCostForObservations } from "./repositories/observations";+export { getLatencyAndTotalCostForObservationsByTraces } from "./repositories/observations";+export { type ObservationTuple } from "./repositories/observations";+export { getObservationsGroupedByTraceId } from "./repositories/observations";+export { getObservationCountsByProjectInCreationInterval } from "./repositories/observations";+export { getObservationCountOfProjectsSinceCreationDate } from "./repositories/observations";+export { getTraceIdsForObservations } from "./repositories/observations";+export { getObservationsForBlobStorageExport } from "./repositories/observations";+export { getObservationsForBlobStorageExportRaw } from "./repositories/observations";+export { getObservationsForBlobStorageExportParquet } from "./repositories/observations";+export { getGenerationsForAnalyticsIntegrations } from "./repositories/observations";+export { getObservationCountsByProjectAndDay } from "./repositories/observations";+export { getCostByEvaluatorIds } from "./repositories/observations";+export { getAvgCostByEvaluatorIdsFromObservations } from "./repositories/observations";+export { generateObservationsForPublicApi } from "./repositories/observations";+export { getObservationsCountForPublicApi } from "./repositories/observations";+export { type EventBatchIOStringOutput } from "./repositories/events";+export { type EventBatchIOSkillFields } from "./repositories/events";+export { type EventBatchIOToolCallFields } from "./repositories/events";+export { type EventBatchIOWithExperimentOutput } from "./repositories/events";+export { type EventBatchIOResult } from "./repositories/events";+export { type ObservationIOSizeFields } from "./repositories/events";+export { MAX_OBSERVATIONS_PER_TRACE } from "./repositories/events";+export { getObservationsForTraceFromEventsTable } from "./repositories/events";+export { getObservationsCountFromEventsTable } from "./repositories/events";+export { getObservationsCountsFromEventsTable } from "./repositories/events";+export { getObservationsWithModelDataFromEventsTable } from "./repositories/events";+export { getObservationMetricsForPromptsFromEvents } from "./repositories/events";+export { getObservationsWithPromptNameFromEvents } from "./repositories/events";+export { getTraceDeleteCursorPageFromEvents } from "./repositories/events";+export { getObservationByIdFromEventsTable } from "./repositories/events";+export { getTraceByIdFromEventsTable } from "./repositories/events";++export { hasAnyTraceFromEventsTable } from "./repositories/events";+export { hasAnyTracingData } from "./repositories/events";+export { getLastTraceTimestampsByProjectsFromEventsTable } from "./repositories/events";+export { getLastTraceTimestampsByProjects } from "./repositories/events";+export { getObservationsFromEventsTableForPublicApi } from "./repositories/events";+export { getObservationsV2FromEventsTableForPublicApi } from "./repositories/events";+export { getObservationsV2PageFromEventsTableForPublicApi } from "./repositories/events";+export { getObservationsCountFromEventsTableForPublicApi } from "./repositories/events";+export { getTracesFromEventsTableForPublicApi } from "./repositories/events";+export { getTracesCountFromEventsTableForPublicApi } from "./repositories/events";+export { updateEvents } from "./repositories/events";+export { getEventsFilterOptionsForColumns } from "./repositories/events";+export { getEventsExactFilterOptionsForColumns } from "./repositories/events";+export { getEventsFilterOptionValuesPage } from "./repositories/events";+export { type EventsMetadataOptionRow } from "./repositories/events";+export { getEventsMetadataValues } from "./repositories/events";+export { getEventsGroupedByTraceTags } from "./repositories/events";+export { getEventsGroupedByUserId } from "./repositories/events";+export { getEventsNumericStatsByFilterColumn } from "./repositories/events";+export { getEventsGroupedByExperimentDatasetId } from "./repositories/events";+export { deleteEventsByTraceIds } from "./repositories/events";+export { hasAnyEvent } from "./repositories/events";+export { deleteEventsByProjectId } from "./repositories/events";+export { getAgentGraphDataFromEventsTable } from "./repositories/events";+export { hasAnyEventOlderThan } from "./repositories/events";+export { deleteEventsOlderThanDays } from "./repositories/events";+export { getObservationsBatchIOFromEventsTable } from "./repositories/events";+export { OBSERVATION_IO_STREAM_FIELDS } from "./repositories/events";+export { type ObservationIoStreamField } from "./repositories/events";+export { getObservationIOFieldByteLengthFromEventsTable } from "./repositories/events";+export { streamObservationIOFieldFromEventsTable } from "./repositories/events";+export { getObservationFullIOForSessionFromEventsTable } from "./repositories/events";+export { getObservationsTraceIdsFromEventsTable } from "./repositories/events";+export { getUsersFromEventsTable } from "./repositories/events";+export { getUsersCountFromEventsTable } from "./repositories/events";+export { getUserMetricsFromEventsTable } from "./repositories/events";+export { hasAnyUserFromEventsTable } from "./repositories/events";+export { getEventsForBlobStorageExport } from "./repositories/events";+export { getEventsForBlobStorageExportRaw } from "./repositories/events";+export { getEventsForBlobStorageExportParquet } from "./repositories/events";+export { getEventsForAnalyticsIntegrations } from "./repositories/events";+export { hasAnySessionFromEventsTable } from "./repositories/events";+export { getTraceMetadataByIdsFromEvents } from "./repositories/events";+export { getAvgCostByEvaluatorIds } from "./repositories/events";+export { getTotalCostByRule } from "./repositories/events";+export { getTotalCostByEvaluatorIds } from "./repositories/events";+export { getLatestEvaluatorRunCost } from "./repositories/events";+export { getEvaluatorExecutionSummaries } from "./repositories/events";+export { getSessionMetricsFromEvents } from "./repositories/events";+export { type SdkMetadata } from "./repositories/events";+export { getLatestSdkVersionInfoFromEvents } from "./repositories/events";+export { getTracesIdentifierForSessionFromEvents } from "./repositories/events";+export { getEventsStreamForEval } from "./repositories/events-stream";+export { getTraceBatchEventStream } from "./repositories/trace-batch";+export { type TableCount } from "./repositories/types";+export { type DateTrunc } from "./repositories/dashboards";+export { getScoreAggregate } from "./repositories/dashboards";+export { getObservationCostByTypeByTime } from "./repositories/dashboards";+export { getObservationUsageByTypeByTime } from "./repositories/dashboards";+export { orderByTimeSeries } from "./repositories/dashboards";+export { selectTimeseriesColumn } from "./repositories/dashboards";+export { extractFromAndToTimestampsFromFilter } from "./repositories/dashboards";+export { convertTraceDomainToClickhouse } from "./repositories/traces_converters";+export { convertClickhouseToDomain } from "./repositories/traces_converters";+export { convertClickhouseTracesListToDomain } from "./repositories/traces_converters";+export { type ScoreAggregation } from "./repositories/scores_converters";+export { convertClickhouseScoreToDomain } from "./repositories/scores_converters";+export { convertScoreAggregation } from "./repositories/scores_converters";+export { type ModelWithPrice } from "./repositories/observations_converters";+export { createModelCache } from "./repositories/observations_converters";+export { convertNumericRecord } from "./repositories/observations_converters";+export { enrichObservationWithModelData } from "./repositories/observations_converters";+export { convertObservationPartial } from "./repositories/observations_converters";+export { convertObservation } from "./repositories/observations_converters";+export { convertEventsObservation } from "./repositories/observations_converters";+export { reduceUsageOrCostDetails } from "./repositories/observations_converters";+export { TupleParam } from "./repositories/clickhouse";+export { ClickHouseResourceError } from "./repositories/clickhouse";+export { upsertClickhouse } from "./repositories/clickhouse";+export { queryClickhouseStream } from "./repositories/clickhouse";+export { queryClickhouseStreamRawText } from "./repositories/clickhouse";+export { BLOB_EXPORT_PARQUET_CLICKHOUSE_SETTINGS } from "./repositories/clickhouse";+export { type ClickhouseExecRawResult } from "./repositories/clickhouse";+export { queryClickhouseExecRaw } from "./repositories/clickhouse";+export { type ClickhouseQueryOpts } from "./repositories/clickhouse";+export { ClickHouseQueryAbortedError } from "./repositories/clickhouse";+export { queryClickhouse } from "./repositories/clickhouse";+export { queryClickhouseWithProgress } from "./repositories/clickhouse";+export { commandClickhouse } from "./repositories/clickhouse";+export { isProgressRow } from "./repositories/clickhouse";+export { isRow } from "./repositories/clickhouse";+export { isException } from "./repositories/clickhouse";+export { type RowOrProgress } from "./repositories/clickhouse";+export { parseClickhouseUTCDateTimeFormat } from "./repositories/clickhouse";+export { clickhouseCompliantRandomCharacters } from "./repositories/clickhouse";+export { OBSERVATIONS_TO_TRACE_INTERVAL_DAYS } from "./repositories/constants";+export { OBSERVATIONS_TO_TRACE_INTERVAL } from "./repositories/constants";+export { TRACE_TO_OBSERVATIONS_INTERVAL } from "./repositories/constants";+export { SCORE_TO_TRACE_OBSERVATIONS_INTERVAL } from "./repositories/constants";+export { isStorableTraceSessionId } from "./repositories/trace-sessions";+export { storableTraceSessionIds } from "./repositories/trace-sessions";+export { getPublicSessionsFilter } from "./repositories/trace-sessions";+export { hasAnySession } from "./repositories/trace-sessions";+export { _handleGetScoreById } from "./repositories/scores-utils";+export { _handleGetScoresByIds } from "./repositories/scores-utils";+export { getBlobStorageByProjectAndEntityId } from "./repositories/blobStorageLog";+export { getBlobStorageByProjectId } from "./repositories/blobStorageLog";+export { getBlobStorageByProjectIdBeforeDate } from "./repositories/blobStorageLog";+export { getBlobStorageByProjectIdAndEntityIds } from "./repositories/blobStorageLog";+export { getBlobStorageByProjectIdAndTraceIds } from "./repositories/blobStorageLog";+export { type EnvironmentFilterProps } from "./repositories/environments";+export { getEnvironmentsForProject } from "./repositories/environments";+export { getActionByIdWithSecrets } from "./repositories/automation-repository";+export { getActionById } from "./repositories/automation-repository";+export { type TriggerDomainWithActions } from "./repositories/automation-repository";+export { getTriggerConfigurations } from "./repositories/automation-repository";+export { convertActionToDomain } from "./repositories/automation-repository";+export { getAutomationById } from "./repositories/automation-repository";+export { getAutomations } from "./repositories/automation-repository";+export { getConsecutiveAutomationFailures } from "./repositories/automation-repository";+export { convertToDatasetRunMetrics } from "./repositories/dataset-run-items-converters";+export { convertDatasetRunItemDomainToClickhouse } from "./repositories/dataset-run-items-converters";+export { convertDatasetRunItemClickhouseToDomain } from "./repositories/dataset-run-items-converters";+export { type DatasetRunsMetrics } from "./repositories/dataset-run-items";+export { type EnrichedDatasetRunItem } from "./repositories/dataset-run-items";+export { getDatasetRunsTableMetricsCh } from "./repositories/dataset-run-items";+export { getDatasetRunsTableRowsCh } from "./repositories/dataset-run-items";+export { getDatasetRunsTableCountCh } from "./repositories/dataset-run-items";+export { getDatasetRunItemsCh } from "./repositories/dataset-run-items";+export { getDatasetRunItemsByDatasetIdCh } from "./repositories/dataset-run-items";+export { getDatasetItemsWithRunDataCount } from "./repositories/dataset-run-items";+export { getDatasetItemIdsWithRunData } from "./repositories/dataset-run-items";+export { getDatasetRunItemsWithoutIOByItemIds } from "./repositories/dataset-run-items";+export { getDatasetItemIdsByTraceIdCh } from "./repositories/dataset-run-items";+export { getDatasetRunItemsCountCh } from "./repositories/dataset-run-items";+export { getDatasetRunItemsCountByDatasetIdCh } from "./repositories/dataset-run-items";+export { hasAnyDatasetRunItem } from "./repositories/dataset-run-items";+export { deleteDatasetRunItemsByProjectId } from "./repositories/dataset-run-items";+export { deleteDatasetRunItemsByDatasetId } from "./repositories/dataset-run-items";+export { deleteDatasetRunItemsByDatasetRunIds } from "./repositories/dataset-run-items";+export { getDatasetRunItemCountsByProjectInCreationInterval } from "./repositories/dataset-run-items";+export { datasetItemsFilterCols } from "./repositories/dataset-items-columns";+export { createDatasetItem } from "./repositories/dataset-items";+export { upsertDatasetItem } from "./repositories/dataset-items";+export { deleteDatasetItem } from "./repositories/dataset-items";+export { createManyDatasetItems } from "./repositories/dataset-items";+export { type PayloadError } from "./repositories/dataset-items";+export { type CreateManyItemsPayload } from "./repositories/dataset-items";+export { type CreateManyItemsInsert } from "./repositories/dataset-items";+export { type CreateManyValidationError } from "./repositories/dataset-items";+export { type ItemBase } from "./repositories/dataset-items";+export { type ItemWithIO } from "./repositories/dataset-items";+export { type ItemWithDatasetName } from "./repositories/dataset-items";+export { createDatasetItemFilterState } from "./repositories/dataset-items";+export { getDatasetItemById } from "./repositories/dataset-items";+export { getDatasetItems } from "./repositories/dataset-items";+export { getDatasetItemsCount } from "./repositories/dataset-items";+export { countDatasetItemVariableMatches } from "./repositories/dataset-items";+export { getDatasetItemsCountGrouped } from "./repositories/dataset-items";+export { listDatasetVersions } from "./repositories/dataset-items";+export { getDatasetVersionForRun } from "./repositories/dataset-items";+export { getDatasetItemVersionHistory } from "./repositories/dataset-items";+export { getDatasetItemChangesSinceVersion } from "./repositories/dataset-items";+export { findDatasetsForDeletion } from "./repositories/datasets";+export { findDatasetIdsForBatchDeletion } from "./repositories/datasets";+export { findDatasetIdsByIds } from "./repositories/datasets";+export { deleteDatasetsByIds } from "./repositories/datasets";+export { findUnresolvableMediaReferences } from "./repositories/dataset-item-media";+export { validateDatasetItemMediaReferences } from "./repositories/dataset-item-media";+export { markDatasetMediaUploadComplete } from "./repositories/dataset-item-media";+export { declarePendingDatasetItemMedia } from "./repositories/dataset-item-media";+export { linkDatasetItemMedia } from "./repositories/dataset-item-media";+export { deleteDatasetItemMediaLinks } from "./repositories/dataset-item-media";+export { type CommentObjectType } from "./repositories/comments";+export { type CommentCountOperator } from "./repositories/comments";+export { type CommentContentOperator } from "./repositories/comments";+export { getObjectIdsByCommentCount } from "./repositories/comments";+export { getObjectIdsByCommentContent } from "./repositories/comments";+export { toAgnosticScoreFilterOptions } from "./repositories/experiments";+export { type AgnosticScoreFilterOptions } from "./repositories/experiments";+export { type ScoreColumnDefinition } from "./repositories/experiments";+export { type ScoreNameLevels } from "./repositories/experiments";+export { type ExperimentEventsDataReturnType } from "./repositories/experiments";+export { type ExperimentMetricsReturnType } from "./repositories/experiments";+export { getDatasetExperimentMetricsFromEvents } from "./repositories/experiments";+export { getExperimentsCountFromEvents } from "./repositories/experiments";+export { getExperimentsFromEvents } from "./repositories/experiments";+export { getExperimentMetricsFromEvents } from "./repositories/experiments";+export { type FetchExperimentsFromEventsProps } from "./repositories/experiments";+export { type ExperimentItemEventsDataReturnType } from "./repositories/experiments";+export { type ExperimentItemData } from "./repositories/experiments";+export { type GroupedExperimentItem } from "./repositories/experiments";+export { type ExperimentItemMetricsReturnType } from "./repositories/experiments";+export { getExperimentItemsCountFromEvents } from "./repositories/experiments";+export { getExperimentItemsFilterOptions } from "./repositories/experiments";+export { getExperimentScoreOptions } from "./repositories/experiments";+export { getExperimentItemsFromEvents } from "./repositories/experiments";+export { type ExperimentOutputData } from "./repositories/experiments";+export { type ExperimentItemBatchIO } from "./repositories/experiments";+export { getExperimentItemsBatchIO } from "./repositories/experiments";+export { getExperimentNamesFromEvents } from "./repositories/experiments";+export { getEvaluatorExecutionStatusCounts } from "./repositories/job-executions";+export { getEvaluatorExecutionStatusCountsByEvaluatorId } from "./repositories/job-executions";+export { generateDailyMetrics } from "./repositories/daily-metrics";+export { getDailyMetricsCount } from "./repositories/daily-metrics";+export { createOrFetchDatasetRun } from "./repositories/dataset-runs";+export { listScoreConfigs } from "./repositories/score-configs";+export { getScoreConfig } from "./repositories/score-configs";+export { type StageAuditLogEventInput } from "./repositories/auditLogs";+export { stageAuditLogEvents } from "./repositories/auditLogs";+export { deriveAuditLogEventId } from "./repositories/auditLogs";+export { convertAuditLogStagingRowToClickhouse } from "./repositories/auditLogs";+export { type BillableEventType } from "./repositories/billable-events";+export { getBillableUnitCountsByProjectInWindow } from "./repositories/billable-events";+export { getTopicSetupTraceCounts } from "./repositories/topic-setup-events";+export { getTopicSetupTraceIds } from "./repositories/topic-setup-events";+export * from "./repositories/observations";export * from "./repositories/traces";export * from "./repositories/dataset-items";@@ -176,17 +722,104 @@ export * from "./redis/llmAsJudgeExecutionQueue";export * from "./redis/codeEvalExecutionQueue";export * from "./services/sessions-ui-table-service";export * from "./services/sessions-ui-table-events-service";-export * from "./services/DashboardService";-export * from "./services/TableViewService";-export * from "./services/DefaultViewService";-export * from "./services/DefaultEvaluationModelService";+export { resolveDashboardWidgetMinVersion } from "./services/DashboardService/DashboardService";+export { DashboardService } from "./services/DashboardService/DashboardService";+export { dashboardWidgetViewToQueryView } from "./services/DashboardService/types";+export { queryViewToDashboardWidgetView } from "./services/DashboardService/types";+export { BaseTimeSeriesChartConfig } from "./services/DashboardService/types";+export { BaseTotalValueChartConfig } from "./services/DashboardService/types";+export { LineChartTimeSeriesConfig } from "./services/DashboardService/types";+export { BarChartTimeSeriesConfig } from "./services/DashboardService/types";+export { AreaChartTimeSeriesConfig } from "./services/DashboardService/types";+export { HorizontalBarChartConfig } from "./services/DashboardService/types";+export { VerticalBarChartConfig } from "./services/DashboardService/types";+export { PieChartConfig } from "./services/DashboardService/types";+export { BigNumberChartConfig } from "./services/DashboardService/types";+export { HistogramChartConfig } from "./services/DashboardService/types";+export { PivotTableChartConfig } from "./services/DashboardService/types";+export { DimensionSchema } from "./services/DashboardService/types";+export { MetricSchema } from "./services/DashboardService/types";+export { ChartConfigSchema } from "./services/DashboardService/types";+export { DashboardDefinitionWidgetWidgetSchema } from "./services/DashboardService/types";+export { DashboardDefinitionPresetWidgetSchema } from "./services/DashboardService/types";+export { DashboardDefinitionWidgetSchema } from "./services/DashboardService/types";+export { DashboardDefinitionSchema } from "./services/DashboardService/types";+export { OwnerEnum } from "./services/DashboardService/types";+export { DashboardDomainSchema } from "./services/DashboardService/types";+export { DashboardListResponseSchema } from "./services/DashboardService/types";+export { WidgetDomainSchema } from "./services/DashboardService/types";+export { CreateWidgetInputSchema } from "./services/DashboardService/types";+export { WidgetListResponseSchema } from "./services/DashboardService/types";+export { type DashboardDefinition } from "./services/DashboardService/types";+export { type DashboardDomain } from "./services/DashboardService/types";+export { type DashboardListResponse } from "./services/DashboardService/types";+export { type WidgetDomain } from "./services/DashboardService/types";+export { type CreateWidgetInput } from "./services/DashboardService/types";+export { type WidgetListResponse } from "./services/DashboardService/types";+export { TableViewService } from "./services/TableViewService/TableViewService";+export { SYSTEM_TABLE_VIEW_PRESET_ID_PREFIX } from "../domain/table-view-presets-catalog";+export { isSystemTableViewPresetId } from "../domain/table-view-presets-catalog";+export { type SystemTableViewPreset } from "../domain/table-view-presets-catalog";+export { getSystemTableViewPresets } from "../domain/table-view-presets-catalog";+export { getSystemTableViewPresetByTableAndId } from "../domain/table-view-presets-catalog";+export { getSystemTableViewPresetById } from "../domain/table-view-presets-catalog";+export { CreateTableViewPresetsInput } from "./services/TableViewService/types";+export { UpdateTableViewPresetsInput } from "./services/TableViewService/types";+export { UpdateTableViewPresetsNameInput } from "./services/TableViewService/types";+export { TableViewPresetsNamesCreatorListSchema } from "./services/TableViewService/types";+export { type TableViewPresetsNamesCreatorList } from "./services/TableViewService/types";+export { DefaultViewService } from "./services/DefaultViewService/DefaultViewService";+export { DefaultViewScope } from "./services/DefaultViewService/types";+export { SetDefaultViewInput } from "./services/DefaultViewService/types";+export { ClearDefaultViewInput } from "./services/DefaultViewService/types";+export { GetDefaultViewInput } from "./services/DefaultViewService/types";+export { DefaultViewAssignmentsSchema } from "./services/DefaultViewService/types";+export { type DefaultViewAssignments } from "./services/DefaultViewService/types";+export { type ResolvedDefault } from "./services/DefaultViewService/types";+export { DefaultEvalModelService } from "./services/DefaultEvaluationModelService/DefaultEvalModelService";export * from "./services/blockEvaluators";export * from "./services/getProjectAdminEmails";export * from "./services/SlackService";export * from "./services/buildColoredAttachmentSlackMessage";export * from "./services/buildSlackLinkSection";-export * from "./tableMappings";-export * from "./otel";+export { observationsTableTraceUiColumnDefinitions } from "./tableMappings/mapObservationsTable";+export { observationsTableUiColumnDefinitions } from "./tableMappings/mapObservationsTable";+export { tracesTableUiColumnDefinitions } from "./tableMappings/mapTracesTable";+export { eventsTableNativeUiColumnDefinitions } from "./tableMappings/mapEventsTable";+export { eventsTableUiColumnDefinitions } from "./tableMappings/mapEventsTable";+export { experimentPreAggCols } from "./tableMappings/mapExperimentTable";+export { experimentScoreAggCols } from "./tableMappings/mapExperimentTable";+export { experimentOrderByCols } from "./tableMappings/mapExperimentTable";+export { experimentCols } from "./tableMappings/mapExperimentTable";+export { publicApiExperimentSimpleFilterMappings } from "./tableMappings/mapExperimentTable";+export { publicApiExperimentColumnMappings } from "./tableMappings/mapExperimentTable";+export { publicApiExperimentColumnDefinitions } from "./tableMappings/mapExperimentTable";+export { publicApiExperimentItemSimpleFilterMappings } from "./tableMappings/mapExperimentTable";+export { publicApiExperimentItemColumnMappings } from "./tableMappings/mapExperimentTable";+export { publicApiExperimentItemColumnDefinitions } from "./tableMappings/mapExperimentTable";+export { dashboardColumnDefinitions } from "../tableDefinitions/mapDashboards";+export { SCORE_BOOLEAN_VALUE_SQL } from "./tableMappings/mapScoresTable";+export { scoresTableUiColumnDefinitions } from "./tableMappings/mapScoresTable";+export { scoresTableUiColumnDefinitionsFromEvents } from "./tableMappings/mapScoresTable";+export { datasetRunItemsTableUiColumnDefinitions } from "./tableMappings/mapDatasetRunItemsTable";+export { mapDatasetRunItemFilterColumn } from "./tableMappings/mapDatasetRunItemsTable";+export { AI_GATEWAY_INSTRUMENTATION_SCOPE_NAME } from "./otel/OtelIngestionProcessor";+export { type OtelIngestionProcessorConfig } from "./otel/OtelIngestionProcessor";+export { type ResourceSpan } from "./otel/OtelIngestionProcessor";+export { OtelIngestionProcessor } from "./otel/OtelIngestionProcessor";+export { type OtelMediaKind } from "./otel/OtelMediaProcessor";+export { type OtelMediaWritePath } from "./otel/OtelMediaProcessor";+export { type OtelMediaPayload } from "./otel/OtelMediaProcessor";+export { type OtelMediaTarget } from "./otel/OtelMediaProcessor";+export { type UploadOtelMedia } from "./otel/OtelMediaProcessor";+export { type OtelMediaProcessResult } from "./otel/OtelMediaProcessor";+export { processOtelMedia } from "./otel/OtelMediaProcessor";+export { internalTraceEventToOtelAttributes } from "./otel/internalTraceOtelWriter";+export { publishOtelResourceSpans } from "./otel/internalTraceOtelWriter";+export { publishInternalOtelSpans } from "./otel/internalTraceOtelWriter";+export { type InternalOtelSpanInput } from "./otel/internalTraceOtelWriter";+export { writeInternalTraceViaOtelIngestion } from "./otel/internalTraceOtelWriter";+export { publishAiFeatureTraceViaOtelIngestion } from "./otel/internalAiFeatureOtelWriter";export * from "./datasets/executeWithDatasetServiceStrategy";export * from "./data-deletion/ingestionFileDeletion";@@ -197,7 +830,21 @@ export * from "./s3";export * from "./dataset-run-items/addToDeleteQueue";// test utils-export * from "./test-utils";+export { createTrace } from "./test-utils/tracing-factory";+export { createDatasetRunItem } from "./test-utils/tracing-factory";+export { createObservation } from "./test-utils/tracing-factory";+export { createTraceScore } from "./test-utils/tracing-factory";+export { createSessionScore } from "./test-utils/tracing-factory";+export { createDatasetRunScore } from "./test-utils/tracing-factory";+export { createEvent } from "./test-utils/tracing-factory";+export { createTracesCh } from "./test-utils/clickhouse-helpers";+export { createObservationsCh } from "./test-utils/clickhouse-helpers";+export { createEventsCh } from "./test-utils/clickhouse-helpers";+export { createScoresCh } from "./test-utils/clickhouse-helpers";+export { createDatasetRunItemsCh } from "./test-utils/clickhouse-helpers";+export { createBasicAuthHeader } from "./test-utils/org-factory";+export { type CreateOrgProjectAndApiKeyOptions } from "./test-utils/org-factory";+export { createOrgProjectAndApiKey } from "./test-utils/org-factory";export * from "./utils/headerUtils";export * from "./utils/formatAuthProvider";export * from "./traceDeletionProcessor";@@ -233,3 +880,15 @@ export const getObservationById = getObservationByIdRoutingWrapper;export const getTracesIdentifierForSession =// eslint-disable-next-line @typescript-eslint/no-deprecated -- Intentional public alias for the deprecated routing wrapper.getTracesIdentifierForSessionRoutingWrapper;++export * from "./billing/billingLedgerShadow";++export { isDnsCompatibleBucketName } from "./outbound-url/validation";+export { assembleTranscriptContext } from "./transcript/context";+export { isExecutionIssue } from "./transcript/context";+export type { ExecutionIssue } from "./transcript/types";+export type { TranscriptContext } from "./transcript/types";+export { getTracingCountsByProjectInCreationIntervalFromEventsTable } from "./repositories/events";+export { AI_GATEWAY_KEY_ID_METADATA_KEY } from "./otel/OtelIngestionProcessor";+export { aiGatewayIngestionApiKey } from "./otel/OtelIngestionProcessor";+export { isAiGatewayIngestionApiKey } from "./otel/OtelIngestionProcessor";diff --git a/packages/shared/src/server/ingestion/modelMatch.ts b/packages/shared/src/server/ingestion/modelMatch.tsindex ae914c8f7f..6e8c936b23 100644--- a/packages/shared/src/server/ingestion/modelMatch.ts+++ b/packages/shared/src/server/ingestion/modelMatch.ts@@ -8,11 +8,11 @@ import {safeMultiDel,scanKeys,} from "../";-import { LocalCache } from "../cache";+import { LocalCache } from "../cache/localCache";import { env } from "../../env";import { Decimal } from "decimal.js";import { prisma } from "../../db";-import type { PricingTierWithPrices } from "../pricing-tiers";+import type { PricingTierWithPrices } from "../pricing-tiers/types";export type ModelMatchProps = {projectId: string;diff --git a/packages/shared/src/server/ingestion/processEventBatch.ts b/packages/shared/src/server/ingestion/processEventBatch.tsindex dab077052e..b051440f9b 100644--- a/packages/shared/src/server/ingestion/processEventBatch.ts+++ b/packages/shared/src/server/ingestion/processEventBatch.ts@@ -3,11 +3,9 @@ import { randomUUID } from "crypto";import { z } from "zod";import { env } from "../../env";-import {- InvalidRequestError,- LangfuseNotFoundError,- UnauthorizedError,-} from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";+import { UnauthorizedError } from "../../errors/UnauthorizedError";import { type AuthHeaderValidVerificationResultIngestion } from "../auth/types";import {getClickhouseEntityType,diff --git a/packages/shared/src/server/ingestion/types.ts b/packages/shared/src/server/ingestion/types.tsindex 4b4a796135..e350bd198e 100644--- a/packages/shared/src/server/ingestion/types.ts+++ b/packages/shared/src/server/ingestion/types.ts@@ -3,8 +3,8 @@ import { z } from "zod";import { isoDateTime, NonEmptyString, jsonSchema } from "../../utils/zod";import { ModelUsageUnit } from "../../constants";-import { ScoreSourceType } from "../../domain";-import { TEXT_SCORE_MAX_LENGTH } from "../../domain/scores";+import { ScoreSourceType, TEXT_SCORE_MAX_LENGTH } from "../../domain/scores";+import { applyScoreValidation } from "../../utils/scores";export const idSchema = zdiff --git a/packages/shared/src/server/ingestion/validateAndInflateScore.ts b/packages/shared/src/server/ingestion/validateAndInflateScore.tsindex 43c17aa336..e8c3a34f6d 100644--- a/packages/shared/src/server/ingestion/validateAndInflateScore.ts+++ b/packages/shared/src/server/ingestion/validateAndInflateScore.ts@@ -10,7 +10,8 @@ import {CORRECTION_NAME,} from "../../../src";import { prisma } from "../../db";-import { InvalidRequestError, LangfuseNotFoundError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";import { validateDbScoreConfigSafe } from "../../features/scoreConfigs/validation";import { ScoreEventType } from "./types";diff --git a/packages/shared/src/server/llm/ai-sdk/providers/bedrock.test.ts b/packages/shared/src/server/llm/ai-sdk/providers/bedrock.test.tsindex 59e78cf14b..3e5afb13ce 100644--- a/packages/shared/src/server/llm/ai-sdk/providers/bedrock.test.ts+++ b/packages/shared/src/server/llm/ai-sdk/providers/bedrock.test.ts@@ -9,7 +9,7 @@ vi.mock("@aws-sdk/credential-providers", () => ({fromNodeProviderChain,}));-import { OutboundUrlValidationError } from "../../../outbound-url";+import { OutboundUrlValidationError } from "../../../outbound-url/validation";import {assertValidBedrockRegion,buildBedrockModel,diff --git a/packages/shared/src/server/llm/ai-sdk/providers/bedrock.ts b/packages/shared/src/server/llm/ai-sdk/providers/bedrock.tsindex 27e88cc7f6..297394b3e1 100644--- a/packages/shared/src/server/llm/ai-sdk/providers/bedrock.ts+++ b/packages/shared/src/server/llm/ai-sdk/providers/bedrock.ts@@ -12,7 +12,7 @@ import {import {OutboundUrlValidationError,parseOutboundUrl,-} from "../../../outbound-url";+} from "../../../outbound-url/validation";import { llmBaseUrlWhitelistFromEnv } from "../../baseUrlValidation";import type { LLMCredentialSource, TranslatedProviderOptions } from "./types";import { isPlainObject } from "./utils";diff --git a/packages/shared/src/server/llm/baseUrlValidation.ts b/packages/shared/src/server/llm/baseUrlValidation.tsindex b8db45ae6f..bdbf7b0232 100644--- a/packages/shared/src/server/llm/baseUrlValidation.ts+++ b/packages/shared/src/server/llm/baseUrlValidation.ts@@ -4,7 +4,7 @@ import {OutboundUrlValidationError,parseOutboundUrl,validateOutboundUrlHost,-} from "../outbound-url";+} from "../outbound-url/validation";export type LlmBaseUrlValidationWhitelist = OutboundUrlValidationWhitelist;diff --git a/packages/shared/src/server/llm/secureLlmFetch.ts b/packages/shared/src/server/llm/secureLlmFetch.tsindex e3a9ad90bc..b65a1b14a6 100644--- a/packages/shared/src/server/llm/secureLlmFetch.ts+++ b/packages/shared/src/server/llm/secureLlmFetch.ts@@ -1,12 +1,15 @@import {CircularRedirectError,fetchWithSecureRedirects,- getOutboundProxyDispatcher,MaxRedirectsExceededError,- OutboundUrlValidationError,RedirectValidationError,+} from "../outbound-url/fetch";+import {+ getOutboundProxyDispatcher,type RequestInitWithDispatcher,-} from "../outbound-url";+} from "../outbound-url/connection";+import { OutboundUrlValidationError } from "../outbound-url/validation";+import {llmBaseUrlWhitelistFromEnv,validateLlmConnectionBaseURL,diff --git a/packages/shared/src/server/media/index.ts b/packages/shared/src/server/media/index.tsdeleted file mode 100644index 43068d3383..0000000000--- a/packages/shared/src/server/media/index.ts+++ /dev/null@@ -1,7 +0,0 @@-export * from "./MediaPayloadProcessor";-export * from "./mediaService";-export {- otelMediaUploads,- forEachMedia,- mediaDispatchConcurrency,-} from "./otelMediaUploads";diff --git a/packages/shared/src/server/media/mediaService.ts b/packages/shared/src/server/media/mediaService.tsindex 2b4fee60b3..5777796214 100644--- a/packages/shared/src/server/media/mediaService.ts+++ b/packages/shared/src/server/media/mediaService.ts@@ -9,7 +9,7 @@ import {type MediaContentType,type MediaField,} from "../../domain/media";-import { InternalServerError } from "../../errors";+import { InternalServerError } from "../../errors/InternalServerError";import { recordHistogram, recordIncrement } from "../instrumentation";import { getS3MediaStorageClient } from "../s3";import { summarizeS3Error } from "../services/s3SigningDiagnostics";diff --git a/packages/shared/src/server/normalized-io/index.ts b/packages/shared/src/server/normalized-io/index.tsdeleted file mode 100644index b728952701..0000000000--- a/packages/shared/src/server/normalized-io/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./parser";-export * from "./projections";diff --git a/packages/shared/src/server/normalized-io/projections/index.ts b/packages/shared/src/server/normalized-io/projections/index.tsdeleted file mode 100644index 16a577dd88..0000000000--- a/packages/shared/src/server/normalized-io/projections/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./eval-record";-export * from "./tool-call-columns";diff --git a/packages/shared/src/server/notifications/index.ts b/packages/shared/src/server/notifications/index.tsdeleted file mode 100644index c885938505..0000000000--- a/packages/shared/src/server/notifications/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from "./types";-export * from "./buildProjectNotificationSlackMessage";-export * from "./dispatchProjectNotification";diff --git a/packages/shared/src/server/orderByToPrisma.ts b/packages/shared/src/server/orderByToPrisma.tsindex 1293bd6c74..0cab01e57f 100644--- a/packages/shared/src/server/orderByToPrisma.ts+++ b/packages/shared/src/server/orderByToPrisma.ts@@ -6,7 +6,7 @@ import { Prisma } from "@prisma/client";import type { ColumnDefinition } from "../tableDefinitions/types";import type { OrderByState } from "../interfaces/orderBy";import { logger } from "./logger";-import { InvalidRequestError } from "../errors";+import { InvalidRequestError } from "../errors/InvalidRequestError";/*** Convert orderBy to SQL ORDER BY clausediff --git a/packages/shared/src/server/otel/index.ts b/packages/shared/src/server/otel/index.tsdeleted file mode 100644index 36d8e0a6a5..0000000000--- a/packages/shared/src/server/otel/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export * from "./OtelIngestionProcessor";-export * from "./OtelMediaProcessor";-export * from "./internalTraceOtelWriter";-export * from "./internalAiFeatureOtelWriter";diff --git a/packages/shared/src/server/outbound-url/index.ts b/packages/shared/src/server/outbound-url/index.tsdeleted file mode 100644index 418cfbc2e9..0000000000--- a/packages/shared/src/server/outbound-url/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export * from "./connection";-export * from "./fetch";-export * from "./noProxy";-export * from "./validation";diff --git a/packages/shared/src/server/pricing-tiers/index.ts b/packages/shared/src/server/pricing-tiers/index.tsdeleted file mode 100644index f59c14a44c..0000000000--- a/packages/shared/src/server/pricing-tiers/index.ts+++ /dev/null@@ -1,12 +0,0 @@-/**- * Shared pricing tier utilities- * Export validation, types, and other utilities for use across the codebase- */--export type {- PricingTierMatchAttributes,- PricingTierMatchResult,- PricingTierWithPrices,-} from "./types";--export { hasPricingTierUsageDetails, matchPricingTier } from "./matcher";diff --git a/packages/shared/src/server/pricing-tiers/matcher.ts b/packages/shared/src/server/pricing-tiers/matcher.tsindex 50bb795037..24f6b8e39a 100644--- a/packages/shared/src/server/pricing-tiers/matcher.ts+++ b/packages/shared/src/server/pricing-tiers/matcher.ts@@ -1,4 +1,4 @@-import { PricingTierCondition } from "../../features/model-pricing";+import { PricingTierCondition } from "../../features/model-pricing/validation";import type {PricingTierMatchAttributes,PricingTierMatchResult,diff --git a/packages/shared/src/server/pricing-tiers/types.ts b/packages/shared/src/server/pricing-tiers/types.tsindex bc6f1c46ab..e20183fb80 100644--- a/packages/shared/src/server/pricing-tiers/types.ts+++ b/packages/shared/src/server/pricing-tiers/types.ts@@ -1,5 +1,5 @@import { type Decimal } from "decimal.js";-import { PricingTierCondition } from "../../features/model-pricing";+import { PricingTierCondition } from "../../features/model-pricing/validation";/*** Shared types for pricing tier functionalitydiff --git a/packages/shared/src/server/prismaFilter.ts b/packages/shared/src/server/prismaFilter.tsindex 00474cb5fa..539dc36c01 100644--- a/packages/shared/src/server/prismaFilter.ts+++ b/packages/shared/src/server/prismaFilter.ts@@ -1,5 +1,5 @@import type { Prisma } from "@prisma/client";-import { InvalidRequestError } from "../errors";+import { InvalidRequestError } from "../errors/InvalidRequestError";import type { FilterState } from "../types";import { escapeSqlLikePattern } from "./utils/sqlLike";diff --git a/packages/shared/src/server/queries/clickhouse-sql/clickhouse-filter.ts b/packages/shared/src/server/queries/clickhouse-sql/clickhouse-filter.tsindex c915b10c68..322368bca9 100644--- a/packages/shared/src/server/queries/clickhouse-sql/clickhouse-filter.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/clickhouse-filter.ts@@ -3,9 +3,9 @@ import {type FtsMatchOperator,filterOperators,} from "../../../interfaces/filters";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { convertDateToClickhouseDateTime } from "../../clickhouse/client";-import { clickhouseCompliantRandomCharacters } from "../../repositories";+import { clickhouseCompliantRandomCharacters } from "../../repositories/clickhouse";import { escapeSqlLikePattern } from "../../utils/sqlLike";import {assertValidFtsMatchFilter,diff --git a/packages/shared/src/server/queries/clickhouse-sql/event-filter-options.ts b/packages/shared/src/server/queries/clickhouse-sql/event-filter-options.tsindex d0d45dab18..e9a9bf3488 100644--- a/packages/shared/src/server/queries/clickhouse-sql/event-filter-options.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/event-filter-options.ts@@ -1,5 +1,5 @@/* eslint-disable no-nested-ternary */-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { UNKNOWN_INGESTION_SDK_VALUE } from "../../ingestion/ingestionAttribution";import {eventsTableCols,diff --git a/packages/shared/src/server/queries/clickhouse-sql/events-observation-row-selection.ts b/packages/shared/src/server/queries/clickhouse-sql/events-observation-row-selection.tsindex 8287a42dd9..cda97291da 100644--- a/packages/shared/src/server/queries/clickhouse-sql/events-observation-row-selection.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/events-observation-row-selection.ts@@ -1,8 +1,8 @@import { eventsTableCols } from "../../../eventsTable";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import type { OrderByState } from "../../../interfaces/orderBy";import type { TracingSearchType } from "../../../interfaces/search";-import { findUiColumnMapping } from "../../../tableDefinitions";+import { findUiColumnMapping } from "../../../tableDefinitions/types";import type { FilterCondition } from "../../../types";import { eventsTableUiColumnDefinitions } from "../../tableMappings/mapEventsTable";import {diff --git a/packages/shared/src/server/queries/clickhouse-sql/events-stream-query.test.ts b/packages/shared/src/server/queries/clickhouse-sql/events-stream-query.test.tsindex 6e59ed242c..fa59f5f9d2 100644--- a/packages/shared/src/server/queries/clickhouse-sql/events-stream-query.test.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/events-stream-query.test.ts@@ -1,6 +1,6 @@import type { FilterCondition } from "../../../types";import type { OrderByState } from "../../../interfaces/orderBy";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { describe, expect, it } from "vitest";import { convertDateToClickhouseDateTime } from "../../clickhouse/client";import {diff --git a/packages/shared/src/server/queries/clickhouse-sql/factory.ts b/packages/shared/src/server/queries/clickhouse-sql/factory.tsindex 25f0396dff..dd7973cced 100644--- a/packages/shared/src/server/queries/clickhouse-sql/factory.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/factory.ts@@ -1,14 +1,15 @@/* eslint-disable @typescript-eslint/no-use-before-define */import { FTS_MATCH_OPERATOR } from "../../../interfaces/filters";import { type EventsTableFilterState } from "../../../types";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { isValidTableName } from "../../clickhouse/schemaUtils";import { logger } from "../../logger";import {findUiColumnMapping,type ColumnDefinition,type UiColumnMappings,-} from "../../../tableDefinitions";+} from "../../../tableDefinitions/types";+import { COMPATIBLE_FILTER_TYPES } from "./filterTypeCompatibility";import {StringFilter,diff --git a/packages/shared/src/server/queries/clickhouse-sql/filterTypeCompatibility.ts b/packages/shared/src/server/queries/clickhouse-sql/filterTypeCompatibility.tsindex 5c3f2a38eb..992921cd4c 100644--- a/packages/shared/src/server/queries/clickhouse-sql/filterTypeCompatibility.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/filterTypeCompatibility.ts@@ -1,4 +1,4 @@-import type { ColumnDefinition } from "../../../tableDefinitions";+import type { ColumnDefinition } from "../../../tableDefinitions/types";import type { FilterCondition } from "../../../types";export type FilterColumnType = ColumnDefinition["type"];diff --git a/packages/shared/src/server/queries/clickhouse-sql/fts.ts b/packages/shared/src/server/queries/clickhouse-sql/fts.tsindex 9bbd4efb77..2d3280ef78 100644--- a/packages/shared/src/server/queries/clickhouse-sql/fts.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/fts.ts@@ -4,7 +4,7 @@ import {type FtsMatchOperator,filterOperators,} from "../../../interfaces/filters";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { EVENTS_TABLE_NAMES } from "../../clickhouse/schema";export { FTS_MATCH_OPERATOR } from "../../../interfaces/filters";diff --git a/packages/shared/src/server/queries/clickhouse-sql/orderby-factory.ts b/packages/shared/src/server/queries/clickhouse-sql/orderby-factory.tsindex 74c32d931a..e76c282645 100644--- a/packages/shared/src/server/queries/clickhouse-sql/orderby-factory.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/orderby-factory.ts@@ -3,8 +3,8 @@ import { OrderByState } from "../../../interfaces/orderBy";import {findUiColumnMapping,UiColumnMappings,-} from "../../../tableDefinitions";-import { InvalidRequestError } from "../../../errors";+} from "../../../tableDefinitions/types";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { logger } from "../../logger";import type { OrderByDirection, OrderByEntry } from "./event-query-builder";diff --git a/packages/shared/src/server/queries/clickhouse-sql/score-filter-pushdown.test.ts b/packages/shared/src/server/queries/clickhouse-sql/score-filter-pushdown.test.tsindex 9eb58657a6..43960fc29e 100644--- a/packages/shared/src/server/queries/clickhouse-sql/score-filter-pushdown.test.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/score-filter-pushdown.test.ts@@ -1,6 +1,6 @@import { describe, expect, it, vi } from "vitest";-vi.mock("../../repositories", () => ({+vi.mock("../../repositories/clickhouse", () => ({clickhouseCompliantRandomCharacters: () => "test",}));diff --git a/packages/shared/src/server/queries/clickhouse-sql/search.ts b/packages/shared/src/server/queries/clickhouse-sql/search.tsindex 2ab40ecb93..ec133d07f0 100644--- a/packages/shared/src/server/queries/clickhouse-sql/search.ts+++ b/packages/shared/src/server/queries/clickhouse-sql/search.ts@@ -1,5 +1,5 @@/* eslint-disable @repo/no-exotic-operators */-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import {hasValidTracingSearchTypes,TRACING_SEARCH_TYPE_REQUIRED_MESSAGE,diff --git a/packages/shared/src/server/queries/createGenerationsQuery.ts b/packages/shared/src/server/queries/createGenerationsQuery.tsindex 7c76581edd..79b9defccf 100644--- a/packages/shared/src/server/queries/createGenerationsQuery.ts+++ b/packages/shared/src/server/queries/createGenerationsQuery.ts@@ -1,9 +1,9 @@import Decimal from "decimal.js";-import {- type Observation,- type EventsObservation,- type ObservationCoreFields,-} from "../../domain";+import type {+ Observation,+ EventsObservation,+ ObservationCoreFields,+} from "../../domain/observations";export type ObservationPriceFields = {inputPrice: Decimal | null;diff --git a/packages/shared/src/server/queries/index.ts b/packages/shared/src/server/queries/index.tsdeleted file mode 100644index a45527e56c..0000000000--- a/packages/shared/src/server/queries/index.ts+++ /dev/null@@ -1,121 +0,0 @@-export {- type FullObservations,- type FullObservationsWithScores,- type FullEventsObservation,- type FullEventsObservations,- type ObservationPriceFields,-} from "./createGenerationsQuery";-export {- type Filter,- FilterList,- StringFilter,- DateTimeFilter,- StringOptionsFilter,- CategoryOptionsFilter,- NumberFilter,- ArrayOptionsFilter,- BooleanFilter,- NumberObjectFilter,- StringObjectFilter,- NullFilter,- encodeBooleanScoreEntry,- filtersRequireEventsFull,- metadataFilterCanPruneEventsFull,- type ClickhouseOperator,-} from "./clickhouse-sql/clickhouse-filter";-export { metadataFilterIsEventsCoreSafe } from "./clickhouse-sql/events-core-truncation";-export {- orderByToClickhouseSql,- orderByToEntries,-} from "./clickhouse-sql/orderby-factory";-export { createFilterFromFilterState } from "./clickhouse-sql/factory";-export {- clickhouseSearchCondition,- type ClickhouseSearchConditionOptions,-} from "./clickhouse-sql/search";-export {- FTS_EVENTS_TABLES,- FTS_MATCH_OPERATOR,- FTS_METADATA_FIELD,- FTS_TEXT_FIELDS,- FTS_TEXT_OPERATORS,- bareFtsField,- hasFtsSearchToken,- isFtsAcceleratedIoOperator,- isFtsEventsTable,- isFtsMatchOperator,- isFtsMetadataField,- isFtsMetadataTarget,- isFtsTextField,- isFtsTextTarget,-} from "./clickhouse-sql/fts";-export { postgresSearchCondition } from "./postgres-sql/search";-export {- convertApiProvidedFilterToClickhouseFilter,- createPublicApiObservationsColumnMapping,- createPublicApiTracesColumnMapping,- deriveFilters,- type ApiColumnMapping,-} from "./public-api-filter-builder";-export {- ALL_SESSION_EVENTS_FIELDS,- CTEQueryBuilder,- EventsAggQueryBuilder,- EventsAggregationQueryBuilder,- EventsSessionAggregationQueryBuilder,- EventsQueryBuilder,- ExperimentsAggregationQueryBuilder,- buildEventsFullTableSplitQuery,- normalizeSessionCounts,- type CTESchema,- type CTEWithSchema,- type QueryWithParams,- type ExperimentsAggregationFieldSetName,- type SessionEventsFields,- type SplitQueryBuilder,-} from "./clickhouse-sql/event-query-builder";-export { OBSERVATION_FIELD_GROUP_FIELD_NAMES } from "../repositories/events-field-sets";-export type {- SessionEventsField,- SessionEventsMetricsRow,-} from "../repositories/events-selects";-export {- buildEventsFilterOptionColumnQuery,- buildEventsFilterOptionsForColumnsQuery,- buildEventsExactFilterOptionsForColumnsQuery,- buildEventsMetadataValuesQuery,- EVENTS_FILTER_OPTION_TOP_N,- EVENTS_APPROX_TOTAL_COUNT_MARKER,- normalizeEventFilterOptionColumn,- type EventFilterOptionRow,- type EventFilterOptionColumn,- type EventFilterOptionScope,-} from "./clickhouse-sql/event-filter-options";-export {- eventsScoresAggregation,- eventsSessionsAggregation,- eventsSessionScoresAggregation,- eventsTraceMetadata,- eventsTracesAggregation,- eventsTracesScoresAggregation,- scoreBooleansAggregation,-} from "./clickhouse-sql/query-fragments";-export {- buildEventsBlobExportStreamQuery,- buildEventsStreamQuery,- type EventsStreamQuery,- type EventsStreamQueryInput,-} from "./clickhouse-sql/events-stream-query";-export {- buildEventsObservationRowSelection,- eventSearchCondition,- groupEventsObservationFilters,- toLevelAgnosticScoreFilter,- type EventsObservationFilterGroups,- type EventsObservationRowSelectionInput,-} from "./clickhouse-sql/events-observation-row-selection";-export { extractTimeFilter } from "./clickhouse-sql/filter-utils";-export {- isSeekEligibleFilter,- scoreOnlyFiltersAreSeekEligible,-} from "./clickhouse-sql/score-seek-eligibility";diff --git a/packages/shared/src/server/queries/public-api-filter-builder.ts b/packages/shared/src/server/queries/public-api-filter-builder.tsindex b0e196903d..31400378a1 100644--- a/packages/shared/src/server/queries/public-api-filter-builder.ts+++ b/packages/shared/src/server/queries/public-api-filter-builder.ts@@ -16,7 +16,7 @@ import type { EventsTableFilterState } from "../../types";import type {UiColumnMappings,ColumnDefinition,-} from "../../tableDefinitions";+} from "../../tableDefinitions/types";import { createFilterFromFilterState } from "./clickhouse-sql/factory";export type ApiColumnMapping = {diff --git a/packages/shared/src/server/queues.ts b/packages/shared/src/server/queues.tsindex a9bc0743a4..61c0cfb2dc 100644--- a/packages/shared/src/server/queues.ts+++ b/packages/shared/src/server/queues.ts@@ -7,7 +7,7 @@ import {BatchActionType,} from "../features/batchAction/types";import { BatchTableNames } from "../interfaces/tableNames";-import { EventActionSchema } from "../domain";+import { EventActionSchema } from "../domain/automations";import { SkillVersionSchema } from "../features/skills/types";import { PromptDomainSchema } from "../domain/prompts";import { ObservationAddToDatasetConfigSchema } from "../features/batchAction/addToDatasetTypes";diff --git a/packages/shared/src/server/repositories/automation-repository.ts b/packages/shared/src/server/repositories/automation-repository.tsindex 36219d928f..84ef8be5d2 100644--- a/packages/shared/src/server/repositories/automation-repository.ts+++ b/packages/shared/src/server/repositories/automation-repository.ts@@ -29,7 +29,7 @@ import {isPagerDutyActionConfig,SafePagerDutyActionConfigSchema,} from "../../domain/automations";-import { InternalServerError } from "../../errors";+import { InternalServerError } from "../../errors/InternalServerError";import { FilterState } from "../../types";import {createDisplayHeaders,diff --git a/packages/shared/src/server/repositories/daily-metrics.ts b/packages/shared/src/server/repositories/daily-metrics.tsindex c1c82f940f..79cf974856 100644--- a/packages/shared/src/server/repositories/daily-metrics.ts+++ b/packages/shared/src/server/repositories/daily-metrics.ts@@ -1,4 +1,8 @@-import { type DateTimeFilter, FilterList } from "../queries";+import {+ type DateTimeFilter,+ FilterList,+} from "../queries/clickhouse-sql/clickhouse-filter";+import { queryClickhouse } from "./clickhouse";import { TRACE_TO_OBSERVATIONS_INTERVAL } from "./constants";import { convertDateToClickhouseDateTime } from "../clickhouse/client";diff --git a/packages/shared/src/server/repositories/dashboards.ts b/packages/shared/src/server/repositories/dashboards.tsindex 1947d2a8a4..7f5a63e690 100644--- a/packages/shared/src/server/repositories/dashboards.ts+++ b/packages/shared/src/server/repositories/dashboards.ts@@ -6,8 +6,11 @@ import {} from "./clickhouse";import { createFilterFromFilterState } from "../queries/clickhouse-sql/factory";import { FilterState } from "../../types";-import { DateTimeFilter, FilterList } from "../queries";-import { dashboardColumnDefinitions } from "../tableMappings";+import {+ DateTimeFilter,+ FilterList,+} from "../queries/clickhouse-sql/clickhouse-filter";+import { dashboardColumnDefinitions } from "../../tableDefinitions/mapDashboards";import { convertDateToClickhouseDateTime } from "../clickhouse/client";import {OBSERVATIONS_TO_TRACE_INTERVAL,diff --git a/packages/shared/src/server/repositories/dataset-item-media.ts b/packages/shared/src/server/repositories/dataset-item-media.tsindex 71e8656585..841ed771b2 100644--- a/packages/shared/src/server/repositories/dataset-item-media.ts+++ b/packages/shared/src/server/repositories/dataset-item-media.ts@@ -1,8 +1,9 @@import { Prisma } from "@prisma/client";import { prisma } from "../../db";-import { type DatasetItemMediaField } from "../../domain";-import { InvalidRequestError, LangfuseNotFoundError } from "../../errors";+import type { DatasetItemMediaField } from "../../domain/dataset-items";+import { InvalidRequestError } from "../../errors/InvalidRequestError";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";import { findMediaReferences } from "../../utils/mediaReferences";import {addTagsToCurrentSpan,diff --git a/packages/shared/src/server/repositories/dataset-items-columns.ts b/packages/shared/src/server/repositories/dataset-items-columns.tsindex 3722828d6f..2148c8ebc5 100644--- a/packages/shared/src/server/repositories/dataset-items-columns.ts+++ b/packages/shared/src/server/repositories/dataset-items-columns.ts@@ -1,5 +1,5 @@import { DatasetStatus } from "@prisma/client";-import { ColumnDefinition } from "../../tableDefinitions";+import { ColumnDefinition } from "../../tableDefinitions/types";export const datasetItemsFilterCols: ColumnDefinition[] = [{diff --git a/packages/shared/src/server/repositories/dataset-items.ts b/packages/shared/src/server/repositories/dataset-items.tsindex 110ae723d2..676795aed2 100644--- a/packages/shared/src/server/repositories/dataset-items.ts+++ b/packages/shared/src/server/repositories/dataset-items.ts@@ -2,13 +2,11 @@ import { Dataset, DatasetItem, DatasetStatus, prisma, Prisma } from "../../db";import type { FilterState } from "../../types";import { tableColumnsToSqlFilterAndPrefix } from "../filterToPrisma";import { datasetItemsFilterCols } from "./dataset-items-columns";-import {- InternalServerError,- InvalidRequestError,- LangfuseConflictError,- LangfuseNotFoundError,-} from "../../errors";-import { DatasetItemValidator } from "../services/DatasetService";+import { InternalServerError } from "../../errors/InternalServerError";+import { InvalidRequestError } from "../../errors/InvalidRequestError";+import { LangfuseConflictError } from "../../errors/ConflictError";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";+import { DatasetItemValidator } from "../services/DatasetService/DatasetItemValidator";import {executeWithDatasetServiceStrategy,Implementation,@@ -27,12 +25,13 @@ import {DatasetItemDomain,DatasetItemDomainWithoutIO,type DatasetItemMediaField,-} from "../../domain";+} from "../../domain/dataset-items";+import {parseClickhouseUTCDateTimeFormat,queryClickhouse,} from "./clickhouse";-import { postgresSearchCondition } from "../queries";+import { postgresSearchCondition } from "../queries/postgres-sql/search";import { TracingSearchType } from "../../interfaces/search";const emptyNormalizeOpts: { sanitizeControlChars?: boolean } = {};diff --git a/packages/shared/src/server/repositories/dataset-run-items.ts b/packages/shared/src/server/repositories/dataset-run-items.tsindex 6e9164d8cc..16eede232b 100644--- a/packages/shared/src/server/repositories/dataset-run-items.ts+++ b/packages/shared/src/server/repositories/dataset-run-items.ts@@ -2,33 +2,34 @@ import { shouldSkipScoresDedup } from "../queries/clickhouse-sql/query-options";import { DatasetRunItemDomain } from "../../domain/dataset-run-items";import { scoreBooleansAggregation } from "../queries/clickhouse-sql/query-fragments";import { type OrderByState } from "../../interfaces/orderBy";-import { datasetRunItemsTableUiColumnDefinitions } from "../tableMappings";+import { datasetRunItemsTableUiColumnDefinitions } from "../tableMappings/mapDatasetRunItemsTable";import { datasetRunsTableUiColumnDefinitions } from "../../tableDefinitions/mapDatasetRunsTable";import { datasetRunItemsTableCols } from "../../tableDefinitions/datasetRunItemsTable";import { datasetRunsTableCols } from "../../tableDefinitions/datasetRunsTable";import { FilterState } from "../../types";+import { createFilterFromFilterState } from "../queries/clickhouse-sql/factory";import {- createFilterFromFilterState,FilterList,- orderByToClickhouseSql,StringFilter,StringOptionsFilter,-} from "../queries";+} from "../queries/clickhouse-sql/clickhouse-filter";+import { orderByToClickhouseSql } from "../queries/clickhouse-sql/orderby-factory";import {parseClickhouseUTCDateTimeFormat,queryClickhouse,+ commandClickhouse,} from "./clickhouse";import { convertDatasetRunItemClickhouseToDomain } from "./dataset-run-items-converters";import { DatasetRunItemRecord } from "./definitions";import { env } from "../../env";-import { commandClickhouse } from "./clickhouse";+import Decimal from "decimal.js";import { ClickHouseClientConfigOptions } from "@clickhouse/client";import {convertDateToClickhouseDateTime,type PreferredClickhouseService,} from "../clickhouse/client";-import { ScoreAggregate } from "../../features/scores";+import { ScoreAggregate } from "../../features/scores/interfaces/ui/types";type DatasetItemIdsByTraceIdQuery = {projectId: string;diff --git a/packages/shared/src/server/repositories/events-stream.ts b/packages/shared/src/server/repositories/events-stream.tsindex c97fa15ab3..591be47420 100644--- a/packages/shared/src/server/repositories/events-stream.ts+++ b/packages/shared/src/server/repositories/events-stream.ts@@ -2,7 +2,7 @@ import { Readable } from "stream";import { normalizeEventsTraceName } from "../../eventsTable";import type { FilterCondition } from "../../types";import type { TracingSearchType } from "../../interfaces/search";-import { buildEventsStreamQuery } from "../queries";+import { buildEventsStreamQuery } from "../queries/clickhouse-sql/events-stream-query";import { queryClickhouseStream } from "./clickhouse";/**diff --git a/packages/shared/src/server/repositories/events.golden.test.ts b/packages/shared/src/server/repositories/events.golden.test.tsindex ac6dfa9cb6..f21756c7dd 100644--- a/packages/shared/src/server/repositories/events.golden.test.ts+++ b/packages/shared/src/server/repositories/events.golden.test.ts@@ -11,7 +11,7 @@ import {import { OBSERVATION_FIELD_GROUPS_FULL } from "../../domain/observation-field-groups";import { eventsTableTraceNameAggregationSql } from "../../eventsTable";import { env } from "../../env";-import { LangfuseNotFoundError } from "../../errors";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";import {capturedQueries,clickhouseFormatAvailable,diff --git a/packages/shared/src/server/repositories/events.ts b/packages/shared/src/server/repositories/events.tsindex 8a0f39b1b5..78b5b2a916 100644--- a/packages/shared/src/server/repositories/events.ts+++ b/packages/shared/src/server/repositories/events.ts@@ -15,15 +15,13 @@ import {} from "kysely";import type {EventsObservation,- MetadataDomain,ObservationType,-} from "../../domain";+} from "../../domain/observations";+import type { MetadataDomain } from "../../domain/traces";import { env } from "../../env";-import {- InternalServerError,- InvalidRequestError,- LangfuseNotFoundError,-} from "../../errors";+import { InternalServerError } from "../../errors/InternalServerError";+import { InvalidRequestError } from "../../errors/InvalidRequestError";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";import {convertDateToClickhouseDateTime,PreferredClickhouseService,@@ -72,22 +70,34 @@ import {import {type Filter,FilterList,+ filtersRequireEventsFull,+} from "../queries/clickhouse-sql/clickhouse-filter";++import {type FullEventsObservation,FullEventsObservations,- buildEventsObservationRowSelection,- extractTimeFilter,+ ObservationPriceFields,+ type EventsObservationPublic,+} from "../queries/createGenerationsQuery";++import { buildEventsObservationRowSelection } from "../queries/clickhouse-sql/events-observation-row-selection";+import { extractTimeFilter } from "../queries/clickhouse-sql/filter-utils";+import {orderByToClickhouseSql,orderByToEntries,+} from "../queries/clickhouse-sql/orderby-factory";+import {createPublicApiObservationsColumnMapping,createPublicApiTracesColumnMapping,deriveFilters,- filtersRequireEventsFull,+ type ApiColumnMapping,+} from "../queries/public-api-filter-builder";+import {isFtsAcceleratedIoOperator,isFtsEventsTable,isFtsTextField,- type ApiColumnMapping,- ObservationPriceFields,-} from "../queries";+} from "../queries/clickhouse-sql/fts";+import { createFilterFromFilterState } from "../queries/clickhouse-sql/factory";import { DateTimeFilter } from "../queries/clickhouse-sql/clickhouse-filter";import { isTimeFilter } from "../queries/clickhouse-sql/filter-utils";@@ -180,7 +190,7 @@ import {type EventFilterOptionColumn,type EventFilterOptionScope,} from "../queries/clickhouse-sql/event-filter-options";-import { type EventsObservationPublic } from "../queries/createGenerationsQuery";+import {eventsTableCols,normalizeEventsTraceName,@@ -191,7 +201,8 @@ import type { TraceDeleteBatchActionCursor } from "../../features/batchAction/tyimport {findUiColumnMapping,type UiColumnMappings,-} from "../../tableDefinitions";+} from "../../tableDefinitions/types";+import { tracesTableCols } from "../../tableDefinitions/tracesTable";import { parseMetadataCHRecordToDomain } from "../utils/metadata_conversion";import { escapeSqlLikePattern } from "../utils/sqlLike";diff --git a/packages/shared/src/server/repositories/experiments.ts b/packages/shared/src/server/repositories/experiments.tsindex dd4170dc45..51210984be 100644--- a/packages/shared/src/server/repositories/experiments.ts+++ b/packages/shared/src/server/repositories/experiments.ts@@ -1,8 +1,8 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-use-before-define */import { EXPERIMENT_IO_TRUNCATE_LENGTH } from "../../constants";-import { matchesUiColumnMapping } from "../../tableDefinitions";+import { matchesUiColumnMapping } from "../../tableDefinitions/types";import { env } from "../../env";-import { type ScoreSourceType } from "../../domain";+import type { ScoreSourceType } from "../../domain/scores";import { type OrderByState } from "../../interfaces/orderBy";import { type FilterState } from "../../types";import { convertDateToClickhouseDateTime } from "../clickhouse/client";@@ -12,13 +12,15 @@ import { avgIf, dateDiff, literal } from "../query-ast/extensions";import {FilterList,StringOptionsFilter,- orderByToClickhouseSql,+ StringFilter,+} from "../queries/clickhouse-sql/clickhouse-filter";+import { orderByToClickhouseSql } from "../queries/clickhouse-sql/orderby-factory";+import {CTEQueryBuilder,CTEWithSchema,EventsAggQueryBuilder,- StringFilter,- extractTimeFilter,-} from "../queries";+} from "../queries/clickhouse-sql/event-query-builder";+import { extractTimeFilter } from "../queries/clickhouse-sql/filter-utils";import { createFilterFromFilterState } from "../queries/clickhouse-sql/factory";import {buildScoreRowsCTE,diff --git a/packages/shared/src/server/repositories/index.ts b/packages/shared/src/server/repositories/index.tsdeleted file mode 100644index 706f905cfd..0000000000--- a/packages/shared/src/server/repositories/index.ts+++ /dev/null@@ -1,33 +0,0 @@-export * from "./scores";-export * from "./traces";-export * from "./observations";-export * from "./events";-export * from "./events-stream";-export * from "./trace-batch";-export * from "./types";-export * from "./dashboards";-export * from "./traces_converters";-export * from "./scores_converters";-export * from "./observations_converters";-export * from "./clickhouse";-export * from "./constants";-export * from "./trace-sessions";-export * from "./scores-utils";-export * from "./blobStorageLog";-export * from "./environments";-export * from "./automation-repository";-export * from "./dataset-run-items-converters";-export * from "./dataset-run-items";-export * from "./dataset-items-columns";-export * from "./dataset-items";-export * from "./datasets";-export * from "./dataset-item-media";-export * from "./comments";-export * from "./experiments";-export * from "./job-executions";-export * from "./daily-metrics";-export * from "./dataset-runs";-export * from "./score-configs";-export * from "./auditLogs";-export * from "./billable-events";-export * from "./topic-setup-events";diff --git a/packages/shared/src/server/repositories/observations.ts b/packages/shared/src/server/repositories/observations.tsindex 8b20433c6e..d1c3741d41 100644--- a/packages/shared/src/server/repositories/observations.ts+++ b/packages/shared/src/server/repositories/observations.ts@@ -11,11 +11,9 @@ import {} from "./clickhouse";import { logger } from "../logger";import { scoreBooleansAggregation } from "../queries/clickhouse-sql/query-fragments";-import {- InternalServerError,- LangfuseNotFoundError,- PayloadTooLargeError,-} from "../../errors";+import { InternalServerError } from "../../errors/InternalServerError";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";+import { PayloadTooLargeError } from "../../errors/PayloadTooLargeError";import { prisma } from "../../db";import { ObservationRecordReadType } from "./definitions";import { FilterState } from "../../types";@@ -23,16 +21,16 @@ import {DateTimeFilter,FilterList,StringFilter,- FullObservations,- orderByToClickhouseSql,-} from "../queries";+} from "../queries/clickhouse-sql/clickhouse-filter";+import { FullObservations } from "../queries/createGenerationsQuery";+import { orderByToClickhouseSql } from "../queries/clickhouse-sql/orderby-factory";import { createFilterFromFilterState } from "../queries/clickhouse-sql/factory";import {observationsTableTraceUiColumnDefinitions,observationsTableUiColumnDefinitions,-} from "../tableMappings";+} from "../tableMappings/mapObservationsTable";import { OrderByState } from "../../interfaces/orderBy";-import { matchesUiColumnMapping } from "../../tableDefinitions";+import { matchesUiColumnMapping } from "../../tableDefinitions/types";import { getTracesByIds } from "./traces";import {convertDateToClickhouseDateTime,@@ -52,7 +50,7 @@ import { TracingSearchType } from "../../interfaces/search";import { observationsTableCols } from "../../observationsTable";import { ClickHouseClientConfigOptions } from "@clickhouse/client";import type { AnalyticsGenerationEvent } from "../analytics-integrations/types";-import { ObservationType } from "../../domain";+import { ObservationType } from "../../domain/observations";import {LEGACY_OBSERVATION_EXPORT_FIELDS,OBSERVATION_FIELD_GROUPS_FULL,diff --git a/packages/shared/src/server/repositories/observations_converters.ts b/packages/shared/src/server/repositories/observations_converters.tsindex 97e47c1d83..1371da0523 100644--- a/packages/shared/src/server/repositories/observations_converters.ts+++ b/packages/shared/src/server/repositories/observations_converters.ts@@ -13,7 +13,7 @@ import {PartialEventsObservation,PartialObservation,ObservationCoreFields,-} from "../../domain";+} from "../../domain/observations";import { parseMetadataCHRecordToDomain } from "../utils/metadata_conversion";import {RenderingProps,diff --git a/packages/shared/src/server/repositories/score-configs.ts b/packages/shared/src/server/repositories/score-configs.tsindex d9fc564df1..a01722af39 100644--- a/packages/shared/src/server/repositories/score-configs.ts+++ b/packages/shared/src/server/repositories/score-configs.ts@@ -3,7 +3,8 @@ import {filterAndValidateDbScoreConfigList,validateDbScoreConfigSafe,} from "../../features/scoreConfigs/validation";-import { LangfuseNotFoundError, InternalServerError } from "../../errors";+import { LangfuseNotFoundError } from "../../errors/NotFoundError";+import { InternalServerError } from "../../errors/InternalServerError";import { traceException } from "../instrumentation";export const listScoreConfigs = async ({diff --git a/packages/shared/src/server/repositories/scores-utils.ts b/packages/shared/src/server/repositories/scores-utils.tsindex fdc78e5c3f..0745bde03a 100644--- a/packages/shared/src/server/repositories/scores-utils.ts+++ b/packages/shared/src/server/repositories/scores-utils.ts@@ -1,5 +1,9 @@import { shouldSkipScoresDedup } from "../queries/clickhouse-sql/query-options";-import { ScoreDataTypeType, ScoreDomain, ScoreSourceType } from "../../domain";+import {+ ScoreDataTypeType,+ ScoreDomain,+ ScoreSourceType,+} from "../../domain/scores";import { PreferredClickhouseService } from "../clickhouse/client";import { queryClickhouse } from "./clickhouse";import { ScoreRecordReadType } from "./definitions";diff --git a/packages/shared/src/server/repositories/scores.ts b/packages/shared/src/server/repositories/scores.tsindex d1912af10b..ef8effac58 100644--- a/packages/shared/src/server/repositories/scores.ts+++ b/packages/shared/src/server/repositories/scores.ts@@ -17,7 +17,8 @@ import {SCORE_EXPORT_GROUP_FIELDS,type ScoreExportFieldGroup,} from "../../domain/export-field-groups";-import { InvalidRequestError, InternalServerError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";+import { InternalServerError } from "../../errors/InternalServerError";import {eventsTableIsRootObservationSql,eventsTableTraceNameSql,@@ -39,23 +40,23 @@ import {} from "./clickhouse";import {FilterList,- orderByToClickhouseSql,StringOptionsFilter,DateTimeFilter,NumberFilter,- scoreOnlyFiltersAreSeekEligible,-} from "../queries";+} from "../queries/clickhouse-sql/clickhouse-filter";+import { orderByToClickhouseSql } from "../queries/clickhouse-sql/orderby-factory";+import { scoreOnlyFiltersAreSeekEligible } from "../queries/clickhouse-sql/score-seek-eligibility";import { FilterCondition, FilterState, TimeFilter } from "../../types";import {createFilterFromFilterState,getProjectIdDefaultFilter,} from "../queries/clickhouse-sql/factory";import { OrderByState } from "../../interfaces/orderBy";+import { dashboardColumnDefinitions } from "../../tableDefinitions/mapDashboards";import {- dashboardColumnDefinitions,scoresTableUiColumnDefinitions,scoresTableUiColumnDefinitionsFromEvents,-} from "../tableMappings";+} from "../tableMappings/mapScoresTable";import {convertScoreAggregation,convertClickhouseScoreToDomain,@@ -95,7 +96,7 @@ import { promptGenerationEvents } from "./prompt-events";import {findUiColumnMapping,matchesUiColumnMapping,-} from "../../tableDefinitions";+} from "../../tableDefinitions/types";const FILTER_OPTION_SCORE_NAME_LIMIT = 200;const FILTER_OPTION_CATEGORICAL_VALUE_LIMIT = 20;diff --git a/packages/shared/src/server/repositories/trace-batch.test.ts b/packages/shared/src/server/repositories/trace-batch.test.tsindex 4127e7820d..99596cdbd4 100644--- a/packages/shared/src/server/repositories/trace-batch.test.ts+++ b/packages/shared/src/server/repositories/trace-batch.test.ts@@ -7,8 +7,8 @@ import { queryClickhouseStream } from "./clickhouse";vi.mock("./clickhouse", async () => ({TupleParam: (await import("@clickhouse/client")).TupleParam,queryClickhouseStream: vi.fn(),+ clickhouseCompliantRandomCharacters: vi.fn(),}));-vi.mock("./index", () => ({ clickhouseCompliantRandomCharacters: vi.fn() }));vi.mock("../clickhouse/client", () => ({convertDateToClickhouseDateTime: vi.fn(),}));diff --git a/packages/shared/src/server/repositories/traces.ts b/packages/shared/src/server/repositories/traces.tsindex dea4070b28..2cb4052571 100644--- a/packages/shared/src/server/repositories/traces.ts+++ b/packages/shared/src/server/repositories/traces.ts@@ -11,7 +11,7 @@ import {createFilterFromFilterState,getProjectIdDefaultFilter,} from "../queries/clickhouse-sql/factory";-import { orderByToClickhouseSql } from "../queries";+import { orderByToClickhouseSql } from "../queries/clickhouse-sql/orderby-factory";import { scoreBooleansAggregation } from "../queries/clickhouse-sql/query-fragments";import {shouldSkipObservationsFinal,@@ -37,7 +37,10 @@ import {} from "../queries/clickhouse-sql/clickhouse-filter";import { TraceRecordReadType } from "./definitions";import { tracesTableUiColumnDefinitions } from "../tableMappings/mapTracesTable";-import { UiColumnMappings, ColumnDefinition } from "../../tableDefinitions";+import {+ UiColumnMappings,+ ColumnDefinition,+} from "../../tableDefinitions/types";import { tracesTableCols } from "../../tableDefinitions/tracesTable";import {convertDateToClickhouseDateTime,@@ -54,11 +57,11 @@ import {} from "./constants";import { env } from "../../env";import { ClickHouseClientConfigOptions } from "@clickhouse/client";-import { recordDistribution } from "../instrumentation";+import { recordDistribution, traceException } from "../instrumentation";import type { AnalyticsTraceEvent } from "../analytics-integrations/types";import { DEFAULT_RENDERING_PROPS, RenderingProps } from "../utils/rendering";import { logger } from "../logger";-import { traceException } from "../instrumentation";+import { prisma } from "../../db";/**diff --git a/packages/shared/src/server/repositories/traces_converters.ts b/packages/shared/src/server/repositories/traces_converters.tsindex 57f38804bb..6e584101d0 100644--- a/packages/shared/src/server/repositories/traces_converters.ts+++ b/packages/shared/src/server/repositories/traces_converters.ts@@ -1,7 +1,7 @@import { parseClickhouseUTCDateTimeFormat } from "./clickhouse";import { TraceRecordExtraFieldsType, TraceRecordReadType } from "./definitions";import { convertDateToClickhouseDateTime } from "../clickhouse/client";-import { TraceDomain } from "../../domain";+import { TraceDomain } from "../../domain/traces";import { parseMetadataCHRecordToDomain } from "../utils/metadata_conversion";import {RenderingProps,diff --git a/packages/shared/src/server/services/DashboardService/DashboardService.ts b/packages/shared/src/server/services/DashboardService/DashboardService.tsindex 734d019f30..34b1157ce5 100644--- a/packages/shared/src/server/services/DashboardService/DashboardService.ts+++ b/packages/shared/src/server/services/DashboardService/DashboardService.ts@@ -4,8 +4,9 @@ import {LangfuseConflictError,LangfuseNotFoundError,type OrderByState,+ singleFilter,} from "../../../";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { env } from "../../../env";import {CreateWidgetInput,@@ -19,7 +20,7 @@ import {dashboardWidgetViewToQueryView,} from "./types";import { z } from "zod";-import { singleFilter } from "../../../";+import {getValidAggregationsForMeasureType,getViewDeclaration,diff --git a/packages/shared/src/server/services/DashboardService/index.ts b/packages/shared/src/server/services/DashboardService/index.tsdeleted file mode 100644index 93b85a5e8e..0000000000--- a/packages/shared/src/server/services/DashboardService/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./DashboardService";-export * from "./types";diff --git a/packages/shared/src/server/services/DatasetService/index.ts b/packages/shared/src/server/services/DatasetService/index.tsdeleted file mode 100644index edc17c4792..0000000000--- a/packages/shared/src/server/services/DatasetService/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./DatasetItemValidator";-export * from "./DatasetSchemaValidator";diff --git a/packages/shared/src/server/services/DefaultEvaluationModelService/DefaultEvalModelService.ts b/packages/shared/src/server/services/DefaultEvaluationModelService/DefaultEvalModelService.tsindex 81aa5c04d2..613661150b 100644--- a/packages/shared/src/server/services/DefaultEvaluationModelService/DefaultEvalModelService.ts+++ b/packages/shared/src/server/services/DefaultEvaluationModelService/DefaultEvalModelService.ts@@ -1,14 +1,13 @@import { EvaluatorBlockReason, Prisma } from "@prisma/client";import z from "zod";import { prisma } from "../../../db";-import { ForbiddenError, LangfuseNotFoundError } from "../../../errors";+import { ForbiddenError } from "../../../errors/ForbiddenError";+import { LangfuseNotFoundError } from "../../../errors/NotFoundError";import { getClientInitiatedNonStreamingLlmTimeoutMs } from "../../llm/llmText";import { LLMAdapter, LLMApiKeySchema, ZodModelConfig } from "../../llm/types";import { testModelCall } from "../../llm/testModelCall";-import {- findCompatibleLlmApiKeysForProjects,- resolveLlmApiKey,-} from "../LLMApiKeys";+import { findCompatibleLlmApiKeysForProjects } from "../LLMApiKeys/findCompatibleLlmApiKeysForProjects";+import { resolveLlmApiKey } from "../LLMApiKeys/LlmApiKeyService";import {blockEvaluatorsUsingDefaultModel,EvaluatorBlockSource,diff --git a/packages/shared/src/server/services/DefaultEvaluationModelService/index.ts b/packages/shared/src/server/services/DefaultEvaluationModelService/index.tsdeleted file mode 100644index 2a770d096f..0000000000--- a/packages/shared/src/server/services/DefaultEvaluationModelService/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./DefaultEvalModelService";diff --git a/packages/shared/src/server/services/DefaultViewService/DefaultViewService.ts b/packages/shared/src/server/services/DefaultViewService/DefaultViewService.tsindex 5901625b09..be9dc13315 100644--- a/packages/shared/src/server/services/DefaultViewService/DefaultViewService.ts+++ b/packages/shared/src/server/services/DefaultViewService/DefaultViewService.ts@@ -3,7 +3,7 @@ import { TableViewPresetTableName } from "../../../domain/table-view-presets";import {getSystemTableViewPresetById,isSystemTableViewPresetId,-} from "../TableViewService/systemPresets";+} from "../../../domain/table-view-presets-catalog";import type {DefaultViewAssignments,DefaultViewScope,diff --git a/packages/shared/src/server/services/DefaultViewService/index.ts b/packages/shared/src/server/services/DefaultViewService/index.tsdeleted file mode 100644index 3f3f9c7234..0000000000--- a/packages/shared/src/server/services/DefaultViewService/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./DefaultViewService";-export * from "./types";diff --git a/packages/shared/src/server/services/LLMApiKeys/index.ts b/packages/shared/src/server/services/LLMApiKeys/index.tsdeleted file mode 100644index 1d1a94f3b1..0000000000--- a/packages/shared/src/server/services/LLMApiKeys/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from "./LlmApiKeyRepository";-export * from "./LlmApiKeyService";-export * from "./findCompatibleLlmApiKeysForProjects";diff --git a/packages/shared/src/server/services/PromptService/index.ts b/packages/shared/src/server/services/PromptService/index.tsindex 58bac03db0..bda50ca828 100644--- a/packages/shared/src/server/services/PromptService/index.ts+++ b/packages/shared/src/server/services/PromptService/index.ts@@ -3,7 +3,7 @@ import { createHash, randomBytes } from "crypto";import { env } from "../../../env";import { logger } from "../../logger";import { escapeRegex } from "./utils";-import { LangfuseConflictError } from "../../../errors";+import { LangfuseConflictError } from "../../../errors/ConflictError";import { type Prisma, type PrismaClient, type Prompt } from "../../../db";import {PromptGraph,diff --git a/packages/shared/src/server/services/StorageService.ts b/packages/shared/src/server/services/StorageService.tsindex ddcb2d90ab..60328b84ca 100644--- a/packages/shared/src/server/services/StorageService.ts+++ b/packages/shared/src/server/services/StorageService.ts@@ -25,7 +25,7 @@ import { logger } from "../logger";import { env } from "../../env";import { normalizeBlobStorageRegion } from "../../utils/stringChecks";import { backOff } from "exponential-backoff";-import { ServiceUnavailableError } from "../../errors";+import { ServiceUnavailableError } from "../../errors/ServiceUnavailableError";import {BufferedStreamUploader,type UploadPartStats,@@ -43,7 +43,8 @@ import { URL } from "node:url";import {getSecureOutboundHttpAgents,type OutboundUrlConnectionValidationOptions,-} from "../outbound-url";+} from "../outbound-url/connection";+import { isS3SlowDownError } from "./s3ThrottleError";export interface S3SseConfig {diff --git a/packages/shared/src/server/services/TableViewService/TableViewService.test.ts b/packages/shared/src/server/services/TableViewService/TableViewService.test.tsindex 013c04b4aa..281937ff5f 100644--- a/packages/shared/src/server/services/TableViewService/TableViewService.test.ts+++ b/packages/shared/src/server/services/TableViewService/TableViewService.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import { TableViewPresetTableName } from "../../../domain/table-view-presets";-import { InvalidRequestError } from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";import { TableViewService } from "./TableViewService";describe("TableViewService.generatePermalink", () => {diff --git a/packages/shared/src/server/services/TableViewService/TableViewService.ts b/packages/shared/src/server/services/TableViewService/TableViewService.tsindex 029782a8b4..241eb81955 100644--- a/packages/shared/src/server/services/TableViewService/TableViewService.ts+++ b/packages/shared/src/server/services/TableViewService/TableViewService.ts@@ -5,11 +5,9 @@ import {TableViewPresetTableName,type TableViewPresetDomain,} from "../../../domain/table-view-presets";-import {- InvalidRequestError,- LangfuseConflictError,- LangfuseNotFoundError,-} from "../../../errors";+import { InvalidRequestError } from "../../../errors/InvalidRequestError";+import { LangfuseConflictError } from "../../../errors/ConflictError";+import { LangfuseNotFoundError } from "../../../errors/NotFoundError";import {TableViewPresetsNamesCreatorList,TableViewPresetsNamesCreatorListSchema,@@ -22,7 +20,7 @@ import {getSystemTableViewPresetByTableAndId,getSystemTableViewPresets,isSystemTableViewPresetId,-} from "./systemPresets";+} from "../../../domain/table-view-presets-catalog";const TABLE_NAME_TO_URL_MAP: Partial<Record<TableViewPresetTableName, string>> ={diff --git a/packages/shared/src/server/services/TableViewService/index.ts b/packages/shared/src/server/services/TableViewService/index.tsdeleted file mode 100644index 18e9f7805e..0000000000--- a/packages/shared/src/server/services/TableViewService/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from "./TableViewService";-export * from "./systemPresets";-export * from "./types";diff --git a/packages/shared/src/server/services/TableViewService/systemPresets.ts b/packages/shared/src/server/services/TableViewService/systemPresets.tsdeleted file mode 100644index badf36b2b2..0000000000--- a/packages/shared/src/server/services/TableViewService/systemPresets.ts+++ /dev/null@@ -1,3 +0,0 @@-// The catalog moved to the domain layer (client-safe data, no server deps);-// re-exported here so server-side callers keep their import path.-export * from "../../../domain/table-view-presets-catalog";diff --git a/packages/shared/src/server/services/blobStorageEndpointValidation.test.ts b/packages/shared/src/server/services/blobStorageEndpointValidation.test.tsindex cccacfd6af..1a4d88cb6c 100644--- a/packages/shared/src/server/services/blobStorageEndpointValidation.test.ts+++ b/packages/shared/src/server/services/blobStorageEndpointValidation.test.ts@@ -4,7 +4,7 @@ import {OutboundUrlValidationError,parseOutboundUrl,validateOutboundResolvedIp,-} from "../outbound-url";+} from "../outbound-url/validation";import {assertGcsBlobStorageBucketAllowed,blobStorageEndpointConnectionValidationOptions,diff --git a/packages/shared/src/server/services/blobStorageEndpointValidation.ts b/packages/shared/src/server/services/blobStorageEndpointValidation.tsindex c1617ca12f..1fae6b71b7 100644--- a/packages/shared/src/server/services/blobStorageEndpointValidation.ts+++ b/packages/shared/src/server/services/blobStorageEndpointValidation.ts@@ -1,15 +1,15 @@import { type BlobStorageIntegrationType } from "@prisma/client";import { env } from "../../env";+import type { OutboundUrlConnectionValidationOptions } from "../outbound-url/connection";import {isDnsCompatibleBucketName,- type OutboundUrlConnectionValidationOptions,type OutboundUrlValidationWhitelist,OutboundUrlValidationError,parseOutboundUrl,resolveHost,validateOutboundResolvedIp,validateOutboundUrlHost,-} from "../outbound-url";+} from "../outbound-url/validation";import { isIPAddress } from "../webhooks/ipBlocking";export const BLOB_STORAGE_ENDPOINT_VALIDATION_LOG_CONTEXT =diff --git a/packages/shared/src/server/services/commentFilterService.test.ts b/packages/shared/src/server/services/commentFilterService.test.tsindex 6b0d1aeea5..75af374c87 100644--- a/packages/shared/src/server/services/commentFilterService.test.ts+++ b/packages/shared/src/server/services/commentFilterService.test.ts@@ -1,5 +1,5 @@import type { PrismaClient } from "../../db";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import { afterEach, describe, expect, it, vi } from "vitest";import * as commentsRepository from "../repositories/comments";import {diff --git a/packages/shared/src/server/services/commentFilterService.ts b/packages/shared/src/server/services/commentFilterService.tsindex 4770570ae3..b7559d4568 100644--- a/packages/shared/src/server/services/commentFilterService.ts+++ b/packages/shared/src/server/services/commentFilterService.ts@@ -1,5 +1,5 @@import type { PrismaClient } from "../../db";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import { type singleFilter } from "../../interfaces/filters";import {type CommentObjectType,diff --git a/packages/shared/src/server/services/externalMediaStorageEndpointValidation/externalMediaStorageEndpointValidation.ts b/packages/shared/src/server/services/externalMediaStorageEndpointValidation/externalMediaStorageEndpointValidation.tsindex 4b78719624..a6a34f75bc 100644--- a/packages/shared/src/server/services/externalMediaStorageEndpointValidation/externalMediaStorageEndpointValidation.ts+++ b/packages/shared/src/server/services/externalMediaStorageEndpointValidation/externalMediaStorageEndpointValidation.ts@@ -1,11 +1,12 @@import { env } from "../../../env";+import type { OutboundUrlConnectionValidationOptions } from "../../outbound-url/connection";import {- type OutboundUrlConnectionValidationOptions,type OutboundUrlValidationWhitelist,OutboundUrlValidationError,parseOutboundUrl,validateOutboundUrlHost,-} from "../../outbound-url";+} from "../../outbound-url/validation";+import {type S3VirtualHostTarget,withS3VirtualHostedBucket,diff --git a/packages/shared/src/server/services/s3ThrottleError.ts b/packages/shared/src/server/services/s3ThrottleError.tsindex 63e22b7276..b675e2357d 100644--- a/packages/shared/src/server/services/s3ThrottleError.ts+++ b/packages/shared/src/server/services/s3ThrottleError.ts@@ -1,4 +1,4 @@-import { ServiceUnavailableError } from "../../errors";+import { ServiceUnavailableError } from "../../errors/ServiceUnavailableError";import { recordIncrement } from "../instrumentation";const MAX_CAUSE_DEPTH = 8;diff --git a/packages/shared/src/server/services/s3VirtualHostedAllowlist.ts b/packages/shared/src/server/services/s3VirtualHostedAllowlist.tsindex 1d5b4c0f7b..dc885024f4 100644--- a/packages/shared/src/server/services/s3VirtualHostedAllowlist.ts+++ b/packages/shared/src/server/services/s3VirtualHostedAllowlist.ts@@ -3,7 +3,7 @@ import {isDnsCompatibleBucketName,type OutboundUrlValidationWhitelist,parseOutboundUrl,-} from "../outbound-url";+} from "../outbound-url/validation";export type S3VirtualHostTarget = {endpoint?: string | null;diff --git a/packages/shared/src/server/services/sessions-ui-table-events-service.ts b/packages/shared/src/server/services/sessions-ui-table-events-service.tsindex 268173e13e..ee400e84e1 100644--- a/packages/shared/src/server/services/sessions-ui-table-events-service.ts+++ b/packages/shared/src/server/services/sessions-ui-table-events-service.ts@@ -1,6 +1,6 @@/* eslint-disable @typescript-eslint/no-use-before-define */import { ClickHouseClientConfigOptions } from "@clickhouse/client";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import { OrderByState } from "../../interfaces/orderBy";import { FilterState } from "../../types";import { convertDateToClickhouseDateTime } from "../clickhouse/client";@@ -8,16 +8,23 @@ import {ALL_SESSION_EVENTS_FIELDS,CTEQueryBuilder,normalizeSessionCounts,+ type SessionEventsFields,+} from "../queries/clickhouse-sql/event-query-builder";+import {DateTimeFilter,FilterList,StringOptionsFilter,filtersRequireEventsFull,metadataFilterCanPruneEventsFull,- orderByToClickhouseSql,+} from "../queries/clickhouse-sql/clickhouse-filter";+import { orderByToClickhouseSql } from "../queries/clickhouse-sql/orderby-factory";+import {type SessionEventsField,- type SessionEventsFields,type SessionEventsMetricsRow,-} from "../queries";+ TRACE_AGGREGATION_FIELDS,+ traceAggregationSelects,+} from "../repositories/events-selects";+import { createFilterFromFilterState } from "../queries/clickhouse-sql/factory";import { compileClickhouseQuery } from "../query-ast/compile";import { getClickhouseKysely } from "../query-ast/dialect";@@ -25,18 +32,17 @@ import {eventsSessionsAggregation,eventsSessionScoresAggregation,} from "../queries/clickhouse-sql/query-fragments";-import { queryClickhouse } from "../repositories";import {- TRACE_AGGREGATION_FIELDS,- traceAggregationSelects,-} from "../repositories/events-selects";+ queryClickhouse,+ parseClickhouseUTCDateTimeFormat,+} from "../repositories/clickhouse";+import {sessionEventsCols,sessionEventsOrderByCols,} from "../tableMappings/mapSessionTable";import { sessionsEventsViewCols } from "../../tableDefinitions/sessionsView";-import { findUiColumnMapping } from "../../tableDefinitions";-import { parseClickhouseUTCDateTimeFormat } from "../repositories/clickhouse";+import { findUiColumnMapping } from "../../tableDefinitions/types";export type SessionTraceFromEvents = {id: string;diff --git a/packages/shared/src/server/services/sessions-ui-table-service.ts b/packages/shared/src/server/services/sessions-ui-table-service.tsindex 7422887354..58d5f4a166 100644--- a/packages/shared/src/server/services/sessions-ui-table-service.ts+++ b/packages/shared/src/server/services/sessions-ui-table-service.ts@@ -5,21 +5,23 @@ import { OrderByState } from "../../interfaces/orderBy";import { sessionCols } from "../tableMappings/mapSessionTable";import { FilterState } from "../../types";import { sessionsViewCols } from "../../tableDefinitions/sessionsView";-import { findUiColumnMapping } from "../../tableDefinitions";+import { findUiColumnMapping } from "../../tableDefinitions/types";import {convertDateToClickhouseDateTime,type PreferredClickhouseService,} from "../clickhouse/client";import { scoreBooleansAggregation } from "../queries/clickhouse-sql/query-fragments";-import { DateTimeFilter, FilterList, orderByToClickhouseSql } from "../queries";+import {+ DateTimeFilter,+ FilterList,+} from "../queries/clickhouse-sql/clickhouse-filter";+import { orderByToClickhouseSql } from "../queries/clickhouse-sql/orderby-factory";import {getProjectIdDefaultFilter,createFilterFromFilterState,} from "../queries/clickhouse-sql/factory";-import {- TRACE_TO_OBSERVATIONS_INTERVAL,- queryClickhouse,-} from "../repositories";+import { TRACE_TO_OBSERVATIONS_INTERVAL } from "../repositories/constants";+import { queryClickhouse } from "../repositories/clickhouse";export type SessionDataReturnType = {session_id: string;diff --git a/packages/shared/src/server/services/traces-ui-table-service.test.ts b/packages/shared/src/server/services/traces-ui-table-service.test.tsindex 3af06d6c60..d8ff7b7327 100644--- a/packages/shared/src/server/services/traces-ui-table-service.test.ts+++ b/packages/shared/src/server/services/traces-ui-table-service.test.ts@@ -4,7 +4,23 @@ const mockQueryClickhouse = vi.hoisted(() => vi.fn());const mockShouldSkipObservationsFinal = vi.hoisted(() => vi.fn());const mockClickhouseCompliantRandomCharacters = vi.hoisted(() => vi.fn());-vi.mock("../repositories", () => ({+vi.mock("../repositories/constants", () => ({+ OBSERVATIONS_TO_TRACE_INTERVAL: "INTERVAL 2 DAY",+ SCORE_TO_TRACE_OBSERVATIONS_INTERVAL: "INTERVAL 1 HOUR",+ clickhouseCompliantRandomCharacters: mockClickhouseCompliantRandomCharacters,+ parseClickhouseUTCDateTimeFormat: (date: string) => new Date(date),+ queryClickhouse: mockQueryClickhouse,+ reduceUsageOrCostDetails: (details: Record<string, number>) => details,+}));+vi.mock("../repositories/clickhouse", () => ({+ OBSERVATIONS_TO_TRACE_INTERVAL: "INTERVAL 2 DAY",+ SCORE_TO_TRACE_OBSERVATIONS_INTERVAL: "INTERVAL 1 HOUR",+ clickhouseCompliantRandomCharacters: mockClickhouseCompliantRandomCharacters,+ parseClickhouseUTCDateTimeFormat: (date: string) => new Date(date),+ queryClickhouse: mockQueryClickhouse,+ reduceUsageOrCostDetails: (details: Record<string, number>) => details,+}));+vi.mock("../repositories/observations_converters", () => ({OBSERVATIONS_TO_TRACE_INTERVAL: "INTERVAL 2 DAY",SCORE_TO_TRACE_OBSERVATIONS_INTERVAL: "INTERVAL 1 HOUR",clickhouseCompliantRandomCharacters: mockClickhouseCompliantRandomCharacters,diff --git a/packages/shared/src/server/services/traces-ui-table-service.ts b/packages/shared/src/server/services/traces-ui-table-service.tsindex d55e68e008..f79c1800ec 100644--- a/packages/shared/src/server/services/traces-ui-table-service.ts+++ b/packages/shared/src/server/services/traces-ui-table-service.ts@@ -1,8 +1,8 @@import { OrderByState } from "../../interfaces/orderBy";import { scoreBooleansAggregation } from "../queries/clickhouse-sql/query-fragments";-import { tracesTableUiColumnDefinitions } from "../tableMappings";+import { tracesTableUiColumnDefinitions } from "../tableMappings/mapTracesTable";import { tracesTableCols } from "../../tableDefinitions/tracesTable";-import { findUiColumnMapping } from "../../tableDefinitions";+import { findUiColumnMapping } from "../../tableDefinitions/types";import { FilterState } from "../../types";import {StringFilter,@@ -17,16 +17,19 @@ import { orderByToClickhouseSql } from "../queries/clickhouse-sql/orderby-factorimport { clickhouseSearchCondition } from "../queries/clickhouse-sql/search";import { TraceRecordReadType } from "../repositories/definitions";import Decimal from "decimal.js";-import { ScoreAggregate } from "../../features/scores";+import { ScoreAggregate } from "../../features/scores/interfaces/ui/types";import {OBSERVATIONS_TO_TRACE_INTERVAL,SCORE_TO_TRACE_OBSERVATIONS_INTERVAL,+} from "../repositories/constants";+import {parseClickhouseUTCDateTimeFormat,queryClickhouse,- reduceUsageOrCostDetails,-} from "../repositories";+} from "../repositories/clickhouse";+import { reduceUsageOrCostDetails } from "../repositories/observations_converters";import { TracingSearchType } from "../../interfaces/search";-import { ObservationLevelType, TraceDomain } from "../../domain";+import { ObservationLevelType } from "../../domain/observations";+import { TraceDomain } from "../../domain/traces";import { ClickHouseClientConfigOptions } from "@clickhouse/client";import {shouldSkipObservationsFinal,diff --git a/packages/shared/src/server/tableMappings/index.ts b/packages/shared/src/server/tableMappings/index.tsdeleted file mode 100644index b6361303c0..0000000000--- a/packages/shared/src/server/tableMappings/index.ts+++ /dev/null@@ -1,7 +0,0 @@-export * from "./mapObservationsTable";-export * from "./mapTracesTable";-export * from "./mapEventsTable";-export * from "./mapExperimentTable";-export * from "../../tableDefinitions/mapDashboards";-export * from "./mapScoresTable";-export * from "./mapDatasetRunItemsTable";diff --git a/packages/shared/src/server/tableMappings/mapDatasetRunItemsTable.ts b/packages/shared/src/server/tableMappings/mapDatasetRunItemsTable.tsindex 46074bb9e9..7519911bf9 100644--- a/packages/shared/src/server/tableMappings/mapDatasetRunItemsTable.ts+++ b/packages/shared/src/server/tableMappings/mapDatasetRunItemsTable.ts@@ -1,7 +1,7 @@import {matchesUiColumnMapping,UiColumnMappings,-} from "../../tableDefinitions";+} from "../../tableDefinitions/types";import { DatasetRunItemDomain } from "../../domain/dataset-run-items";export const datasetRunItemsTableUiColumnDefinitions: UiColumnMappings = [diff --git a/packages/shared/src/server/tableMappings/mapEventsTable.ts b/packages/shared/src/server/tableMappings/mapEventsTable.tsindex 5bafd85ba7..5c39638939 100644--- a/packages/shared/src/server/tableMappings/mapEventsTable.ts+++ b/packages/shared/src/server/tableMappings/mapEventsTable.ts@@ -1,7 +1,7 @@// This structure is maintained to relate the frontend table definitions with the clickhouse table definitions.// The frontend only sends the column names to the backend. This needs to be changed in the future to send column IDs.-import { UiColumnMappings } from "../../tableDefinitions";+import { UiColumnMappings } from "../../tableDefinitions/types";import {eventsTableHasParentObservationSql,eventsTableIsRootObservationSql,diff --git a/packages/shared/src/server/tableMappings/mapExperimentItemsTable.ts b/packages/shared/src/server/tableMappings/mapExperimentItemsTable.tsindex 1cadef7a55..8f8b3d9920 100644--- a/packages/shared/src/server/tableMappings/mapExperimentItemsTable.ts+++ b/packages/shared/src/server/tableMappings/mapExperimentItemsTable.ts@@ -1,4 +1,4 @@-import { UiColumnMappings } from "../../tableDefinitions";+import { UiColumnMappings } from "../../tableDefinitions/types";export const experimentItemsTableNativeUiColumnDefinitions: UiColumnMappings = [{diff --git a/packages/shared/src/server/tableMappings/mapExperimentTable.ts b/packages/shared/src/server/tableMappings/mapExperimentTable.tsindex c321225760..e4a87f128c 100644--- a/packages/shared/src/server/tableMappings/mapExperimentTable.ts+++ b/packages/shared/src/server/tableMappings/mapExperimentTable.ts@@ -1,7 +1,7 @@import type {ColumnDefinition,UiColumnMappings,-} from "../../tableDefinitions";+} from "../../tableDefinitions/types";import type { ApiColumnMapping } from "../queries/public-api-filter-builder";/**diff --git a/packages/shared/src/server/tableMappings/mapObservationsTable.ts b/packages/shared/src/server/tableMappings/mapObservationsTable.tsindex 412f5fe76e..d19232b6b5 100644--- a/packages/shared/src/server/tableMappings/mapObservationsTable.ts+++ b/packages/shared/src/server/tableMappings/mapObservationsTable.ts@@ -1,7 +1,7 @@// This structure is maintained to relate the frontend table definitions with the clickhouse table definitions.// The frontend only sends the column names to the backend. This needs to be changed in the future to send column IDs.-import { UiColumnMappings } from "../../tableDefinitions";+import { UiColumnMappings } from "../../tableDefinitions/types";import { tokenCountFilterClickhouseType } from "./tokenCountFilterType";export const observationsTableTraceUiColumnDefinitions: UiColumnMappings = [diff --git a/packages/shared/src/server/tableMappings/mapScoresColumnsTable.ts b/packages/shared/src/server/tableMappings/mapScoresColumnsTable.tsindex 1818e9912c..7442294f55 100644--- a/packages/shared/src/server/tableMappings/mapScoresColumnsTable.ts+++ b/packages/shared/src/server/tableMappings/mapScoresColumnsTable.ts@@ -1,4 +1,4 @@-import { UiColumnMappings } from "../../tableDefinitions";+import { UiColumnMappings } from "../../tableDefinitions/types";import { SCORE_BOOLEAN_VALUE_SQL } from "./mapScoresTable";export const scoresColumnsTableUiColumnDefinitions: UiColumnMappings = [diff --git a/packages/shared/src/server/tableMappings/mapScoresTable.ts b/packages/shared/src/server/tableMappings/mapScoresTable.tsindex 1c9a89a8a0..0367054767 100644--- a/packages/shared/src/server/tableMappings/mapScoresTable.ts+++ b/packages/shared/src/server/tableMappings/mapScoresTable.ts@@ -1,4 +1,4 @@-import { UiColumnMappings } from "../../tableDefinitions";+import { UiColumnMappings } from "../../tableDefinitions/types";import { EvalExecutionMetadataKey } from "../../features/evals/evalExecutionMetadata";// Lowercased boolean string_value ('true'/'false', '' for non-boolean rows) —diff --git a/packages/shared/src/server/tableMappings/mapSessionTable.ts b/packages/shared/src/server/tableMappings/mapSessionTable.tsindex af943600a1..a7ceb1dd1c 100644--- a/packages/shared/src/server/tableMappings/mapSessionTable.ts+++ b/packages/shared/src/server/tableMappings/mapSessionTable.ts@@ -1,4 +1,4 @@-import { UiColumnMappings } from "../../tableDefinitions";+import { UiColumnMappings } from "../../tableDefinitions/types";import { tokenCountFilterClickhouseType } from "./tokenCountFilterType";export const sessionCols: UiColumnMappings = [diff --git a/packages/shared/src/server/tableMappings/mapTracesTable.ts b/packages/shared/src/server/tableMappings/mapTracesTable.tsindex ca20fad782..9ba8870e3e 100644--- a/packages/shared/src/server/tableMappings/mapTracesTable.ts+++ b/packages/shared/src/server/tableMappings/mapTracesTable.ts@@ -1,4 +1,4 @@-import { UiColumnMappings } from "../../tableDefinitions";+import { UiColumnMappings } from "../../tableDefinitions/types";import { EvalExecutionMetadataKey } from "../../features/evals/evalExecutionMetadata";import { tokenCountFilterClickhouseType } from "./tokenCountFilterType";diff --git a/packages/shared/src/server/tableMappings/tokenCountFilters.test.ts b/packages/shared/src/server/tableMappings/tokenCountFilters.test.tsindex 438c063632..ed9bd80a1e 100644--- a/packages/shared/src/server/tableMappings/tokenCountFilters.test.ts+++ b/packages/shared/src/server/tableMappings/tokenCountFilters.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";-import { type UiColumnMappings } from "../../tableDefinitions";+import type { UiColumnMappings } from "../../tableDefinitions/types";import { createFilterFromFilterState } from "../queries/clickhouse-sql/factory";import { eventsTableUiColumnDefinitions } from "./mapEventsTable";import { observationsTableUiColumnDefinitions } from "./mapObservationsTable";diff --git a/packages/shared/src/server/test-utils/index.ts b/packages/shared/src/server/test-utils/index.tsdeleted file mode 100644index ae76cc5f81..0000000000--- a/packages/shared/src/server/test-utils/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from "./tracing-factory";-export * from "./clickhouse-helpers";-export * from "./org-factory";diff --git a/packages/shared/src/server/topics/execution-store.ts b/packages/shared/src/server/topics/execution-store.tsindex 6bbacf98e4..bc987f68a4 100644--- a/packages/shared/src/server/topics/execution-store.ts+++ b/packages/shared/src/server/topics/execution-store.ts@@ -1,7 +1,7 @@import { createHash } from "node:crypto";import { prisma, type Prisma } from "../../db";import { getTopicProcessingMapIds } from "./postgres";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import { BatchActionStatus } from "../../features/batchAction/types";import {topicExecutionInputSchema,diff --git a/packages/shared/src/server/topics/model-config.ts b/packages/shared/src/server/topics/model-config.tsindex 960d1257f6..f71f08049a 100644--- a/packages/shared/src/server/topics/model-config.ts+++ b/packages/shared/src/server/topics/model-config.ts@@ -5,13 +5,13 @@ import {type TopicConfig,} from "@prisma/client";import { prisma } from "../../db";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import {getClientInitiatedNonStreamingLlmTimeoutMs,type LLMConnection,} from "../llm/llmText";import { LLMAdapter } from "../llm/types";-import { findCompatibleLlmApiKeysForProjects } from "../services/LLMApiKeys";+import { findCompatibleLlmApiKeysForProjects } from "../services/LLMApiKeys/findCompatibleLlmApiKeysForProjects";import {TOPICS_MODEL_SLOT_DETAILS,TOPICS_MODEL_SLOTS,diff --git a/packages/shared/src/server/topics/postgres.ts b/packages/shared/src/server/topics/postgres.tsindex 9bef167860..da8af4f8f2 100644--- a/packages/shared/src/server/topics/postgres.ts+++ b/packages/shared/src/server/topics/postgres.ts@@ -14,7 +14,7 @@ import {} from "../../topics";import { isEqual } from "lodash";import { getTopicDefinitions, writeTopicDefinitions } from "./clickhouse";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import { TopicsTargetObject } from "../../features/evals/types";import {invalidateTopicsProcessingActive,diff --git a/packages/shared/src/server/topics/setup.test.ts b/packages/shared/src/server/topics/setup.test.tsindex 860c1d435b..bd3c90c382 100644--- a/packages/shared/src/server/topics/setup.test.ts+++ b/packages/shared/src/server/topics/setup.test.ts@@ -1,5 +1,5 @@import { beforeEach, describe, expect, it, vi } from "vitest";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import { DEFAULT_TOPIC_FACETS } from "../../topics";const mocks = vi.hoisted(() => ({diff --git a/packages/shared/src/server/topics/setup.ts b/packages/shared/src/server/topics/setup.tsindex 938fd684c0..ba7a3737a3 100644--- a/packages/shared/src/server/topics/setup.ts+++ b/packages/shared/src/server/topics/setup.ts@@ -1,5 +1,5 @@import type { z } from "zod";-import { InvalidRequestError } from "../../errors";+import { InvalidRequestError } from "../../errors/InvalidRequestError";import {topicsAutomaticProcessingSchema,topicsSetupSchema,diff --git a/packages/shared/src/server/topics/trace-input.ts b/packages/shared/src/server/topics/trace-input.tsindex 29439d7e0c..7632ca25a5 100644--- a/packages/shared/src/server/topics/trace-input.ts+++ b/packages/shared/src/server/topics/trace-input.ts@@ -5,11 +5,9 @@ import {queryClickhouseStream,} from "../repositories/clickhouse";import { convertDateToClickhouseDateTime } from "../clickhouse/client";-import {- assembleTranscript,- orderObservations,- type TranscriptObservation,-} from "../transcript";+import { assembleTranscript } from "../transcript/transcript";+import { orderObservations } from "../transcript/ordering";+import type { TranscriptObservation } from "../transcript/types";/** Historical summaries are reusable only with the same transcript producer. */export const TOPICS_TRANSCRIPT_VERSION = "shared-transcript-v3";diff --git a/packages/shared/src/server/traceBatch/index.ts b/packages/shared/src/server/traceBatch/index.tsdeleted file mode 100644index 471af5ee79..0000000000--- a/packages/shared/src/server/traceBatch/index.ts+++ /dev/null@@ -1,8 +0,0 @@-export {- createTraceBatchInputStorage,- TRACE_BATCH_INPUT_MAX_CHARACTERS,- UnsupportedTraceBatchInputVersionError,- type TraceBatchInputReference,- type TraceBatchInputData,- type TraceBatchInputStorage,-} from "./storage";diff --git a/packages/shared/src/server/traceBatch/serialization.test.ts b/packages/shared/src/server/traceBatch/serialization.test.tsindex 21805fcbda..d89b473409 100644--- a/packages/shared/src/server/traceBatch/serialization.test.ts+++ b/packages/shared/src/server/traceBatch/serialization.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import { transcriptFixtures } from "../transcript/fixtures";-import { createObservation } from "../test-utils";+import { createObservation } from "../test-utils/tracing-factory";import { convertObservation } from "../repositories/observations_converters";import { orderObservations } from "../transcript/ordering";import { assembleTranscript } from "../transcript/transcript";diff --git a/packages/shared/src/server/transcript/fixtures/fixture-types.ts b/packages/shared/src/server/transcript/fixtures/fixture-types.tsindex bc781338f3..259514ddf3 100644--- a/packages/shared/src/server/transcript/fixtures/fixture-types.ts+++ b/packages/shared/src/server/transcript/fixtures/fixture-types.ts@@ -1,4 +1,4 @@-import { createObservation } from "../../test-utils";+import { createObservation } from "../../test-utils/tracing-factory";import type { Transcript } from "../types";/**diff --git a/packages/shared/src/server/transcript/fixtures/fixtures.test.ts b/packages/shared/src/server/transcript/fixtures/fixtures.test.tsindex e0123758af..8a1c81129b 100644--- a/packages/shared/src/server/transcript/fixtures/fixtures.test.ts+++ b/packages/shared/src/server/transcript/fixtures/fixtures.test.ts@@ -1,6 +1,6 @@import { describe, expect, it, vi } from "vitest";import { transcriptFixtures } from "./index";-import { createObservation } from "../../test-utils";+import { createObservation } from "../../test-utils/tracing-factory";import { convertObservation } from "../../repositories/observations_converters";import { orderObservations } from "../ordering";import { assembleTranscript } from "../transcript";diff --git a/packages/shared/src/server/transcript/generic-renderer.ts b/packages/shared/src/server/transcript/generic-renderer.tsindex fd50acf158..30bafd0d0e 100644--- a/packages/shared/src/server/transcript/generic-renderer.ts+++ b/packages/shared/src/server/transcript/generic-renderer.ts@@ -1,10 +1,10 @@-import type { Observation } from "../../domain";+import type { Observation } from "../../domain/observations";import type {NormalizedMessage,NormalizedMessagePart,ToolResultContentPart,} from "../../utils/normalized-io";-import { normalizeIO } from "../normalized-io";+import { normalizeIO } from "../normalized-io/parser";import {topicsTranscriptConfig,transcriptRenderConfigSchema,diff --git a/packages/shared/src/server/transcript/index.ts b/packages/shared/src/server/transcript/index.tsdeleted file mode 100644index e383b258a6..0000000000--- a/packages/shared/src/server/transcript/index.ts+++ /dev/null@@ -1,16 +0,0 @@-export { orderObservations } from "./ordering";-export { assembleTranscript } from "./transcript";-export { assembleTranscriptContext, isExecutionIssue } from "./context";-export {- renderTranscript,- renderTranscriptFromObservations,- transcriptBlockTypes,-} from "./topics-renderer";-export { renderGenericTranscript } from "./generic-renderer";-export {- topicsTranscriptConfig,- transcriptRenderConfigSchema,-} from "./topics-renderer-config";-export type { TranscriptRenderConfig } from "./topics-renderer-config";-export type { TranscriptBlockType } from "./topics-renderer";-export type * from "./types";diff --git a/packages/shared/src/server/transcript/ordering.test.ts b/packages/shared/src/server/transcript/ordering.test.tsindex e38ffd2d13..8ebdc8b431 100644--- a/packages/shared/src/server/transcript/ordering.test.ts+++ b/packages/shared/src/server/transcript/ordering.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from "vitest";-import type { Observation } from "../../domain";+import type { Observation } from "../../domain/observations";import { orderObservations } from "./ordering";describe("orderObservations", () => {diff --git a/packages/shared/src/server/transcript/topics-renderer.test.ts b/packages/shared/src/server/transcript/topics-renderer.test.tsindex 687d197319..e7b617419a 100644--- a/packages/shared/src/server/transcript/topics-renderer.test.ts+++ b/packages/shared/src/server/transcript/topics-renderer.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import { convertObservation } from "../repositories/observations_converters";-import { createObservation } from "../test-utils";+import { createObservation } from "../test-utils/tracing-factory";import { inheritedConversationHistoryFixture } from "./fixtures/trace/inherited-conversation-history";import { standaloneToolObservationFixture } from "./fixtures/trace/standalone-tool-observation";import { orderObservations } from "./ordering";diff --git a/packages/shared/src/server/transcript/topics-renderer.ts b/packages/shared/src/server/transcript/topics-renderer.tsindex c32e8ac11f..0c60e8fd37 100644--- a/packages/shared/src/server/transcript/topics-renderer.ts+++ b/packages/shared/src/server/transcript/topics-renderer.ts@@ -1,10 +1,10 @@/* eslint-disable @typescript-eslint/no-use-before-define */-import type { Observation } from "../../domain";+import type { Observation } from "../../domain/observations";import type {NormalizedMessage,NormalizedMessagePart,} from "../../utils/normalized-io";-import { normalizeIO } from "../normalized-io";+import { normalizeIO } from "../normalized-io/parser";import { orderObservations } from "./ordering";import { assembleTranscript } from "./transcript";import { isExecutionIssue } from "./context";diff --git a/packages/shared/src/server/transcript/transcript.ts b/packages/shared/src/server/transcript/transcript.tsindex c9bb00172b..53af87c127 100644--- a/packages/shared/src/server/transcript/transcript.ts+++ b/packages/shared/src/server/transcript/transcript.ts@@ -1,6 +1,6 @@import { partition } from "lodash";import type { OrderedObservation } from "./ordering";-import { normalizeIO } from "../normalized-io";+import { normalizeIO } from "../normalized-io/parser";import type { Transcript, TranscriptOptions } from "./types";import { limitTranscript } from "./limit";import {diff --git a/packages/shared/src/server/transcript/types.ts b/packages/shared/src/server/transcript/types.tsindex a4558f5fc4..683f2d7d1b 100644--- a/packages/shared/src/server/transcript/types.ts+++ b/packages/shared/src/server/transcript/types.ts@@ -6,7 +6,7 @@ import type {executionIssueSchema,transcriptSchema,} from "./schema";-import type { Observation } from "../../domain";+import type { Observation } from "../../domain/observations";export type TranscriptOptions = {/** Hard limit on JSON.stringify(result).length, including metadata and escaping.diff --git a/packages/shared/src/server/utils/metadata_conversion.ts b/packages/shared/src/server/utils/metadata_conversion.tsindex c93d9abdec..0ec0ae6016 100644--- a/packages/shared/src/server/utils/metadata_conversion.ts+++ b/packages/shared/src/server/utils/metadata_conversion.ts@@ -1,5 +1,5 @@import { parseJsonPrioritised } from "../../utils/json";-import { MetadataDomain } from "../../domain";+import { MetadataDomain } from "../../domain/traces";/*** Zips parallel ClickHouse array columns (`metadata_names`, `metadata_values`)diff --git a/packages/shared/src/server/webhooks/validation.ts b/packages/shared/src/server/webhooks/validation.tsindex 681594182f..8f2e99c4c6 100644--- a/packages/shared/src/server/webhooks/validation.ts+++ b/packages/shared/src/server/webhooks/validation.ts@@ -1,11 +1,11 @@import { env } from "../../env";import {OutboundUrlValidationError,- type OutboundUrlValidationWhitelist,parseOutboundUrl,resolveHost,validateOutboundUrlHost,-} from "../outbound-url";+ type OutboundUrlValidationWhitelist,+} from "../outbound-url/validation";export type WebhookValidationWhitelist = OutboundUrlValidationWhitelist;export { resolveHost };diff --git a/packages/shared/src/tableDefinitions/index.ts b/packages/shared/src/tableDefinitions/index.tsdeleted file mode 100644index cdb0a9a381..0000000000--- a/packages/shared/src/tableDefinitions/index.ts+++ /dev/null@@ -1,11 +0,0 @@-export * from "./sessionsView";-export * from "./types";-export * from "./mapDashboards";-export * from "./monitorsTable";-export * from "./promptsTable";-export * from "./datasetItemsTable";-export * from "./mapDatasetRunsTable";-export * from "./datasetRunsTable";-export * from "./datasetRunItemsTable";-export * from "./usersTable";-export * from "./scoresTable";diff --git a/packages/shared/src/utils/IORepresentation/index.ts b/packages/shared/src/utils/IORepresentation/index.tsdeleted file mode 100644index 73f6309bc5..0000000000--- a/packages/shared/src/utils/IORepresentation/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./parseIO";-export * from "./chatML/types";diff --git a/packages/shared/src/utils/normalized-io/core/accumulator/collect.ts b/packages/shared/src/utils/normalized-io/core/accumulator/collect.tsindex 38923d9d09..e13552a42e 100644--- a/packages/shared/src/utils/normalized-io/core/accumulator/collect.ts+++ b/packages/shared/src/utils/normalized-io/core/accumulator/collect.ts@@ -11,11 +11,9 @@ import type { NormalizedMessage, NormalizedMessagePart } from "../../types";import { addMessage, addToolDefinitionValue } from "./helpers";import type { NormalizedIOAccumulator } from "./interface";import type { ParserContext } from "../parser-context";-import {- normalizePartValue,- normalizeMessage,- normalizeFinishReason,-} from "../normalize";+import { normalizePartValue } from "../normalize/part";+import { normalizeMessage } from "../normalize/message";+import { normalizeFinishReason } from "../normalize/finish-reason";import { isMessageLike, isToolDefinitionMessage } from "../utils/format";export type ParsedIOValue = {diff --git a/packages/shared/src/utils/normalized-io/core/accumulator/index.ts b/packages/shared/src/utils/normalized-io/core/accumulator/index.tsdeleted file mode 100644index 11c43f6eeb..0000000000--- a/packages/shared/src/utils/normalized-io/core/accumulator/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./collect";-export * from "./interface";diff --git a/packages/shared/src/utils/normalized-io/core/normalize/index.ts b/packages/shared/src/utils/normalized-io/core/normalize/index.tsdeleted file mode 100644index 5c03017ad0..0000000000--- a/packages/shared/src/utils/normalized-io/core/normalize/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export * from "./message";-export * from "./part";-export * from "./role";-export * from "./finish-reason";diff --git a/packages/shared/src/utils/normalized-io/parser.ts b/packages/shared/src/utils/normalized-io/parser.tsindex 5d0f57306f..e536817647 100644--- a/packages/shared/src/utils/normalized-io/parser.ts+++ b/packages/shared/src/utils/normalized-io/parser.ts@@ -3,9 +3,10 @@ import type { NormalizedIO, SpanIO } from "./types";import {collectMetadata,collectIO,- createAccumulator,type ParsedIOValue,-} from "./core/accumulator";+} from "./core/accumulator/collect";+import { createAccumulator } from "./core/accumulator/interface";+import { createParserContext } from "./core/parser-context";type ParsedSpanIO = {diff --git a/packages/shared/src/utils/zod.ts b/packages/shared/src/utils/zod.tsindex 6db43e2d2c..2027ef2950 100644--- a/packages/shared/src/utils/zod.ts+++ b/packages/shared/src/utils/zod.ts@@ -1,6 +1,6 @@import { InputJsonValue } from "@prisma/client/runtime/library";import { z } from "zod";-import { InvalidRequestError } from "../errors";+import { InvalidRequestError } from "../errors/InvalidRequestError";/** ISO datetimes with minutes, seconds, or fractional seconds; timezone required. */export function isoDateTime({diff --git a/web/src/__e2e__/ai-gateway.gatewaye2e.ts b/web/src/__e2e__/ai-gateway.gatewaye2e.tsindex 22b05a66f9..b72b0fcbb3 100644--- a/web/src/__e2e__/ai-gateway.gatewaye2e.ts+++ b/web/src/__e2e__/ai-gateway.gatewaye2e.ts@@ -16,8 +16,9 @@ import { $root } from "@/src/pages/api/public/otel/otlp-proto/generated/root";import {type GatewayApiFormat,GatewayResolveResponseSchema,-} from "@/src/features/ai-gateway/server/provider";-import type { GatewayProviderName } from "@/src/features/ai-gateway/server/provider/registry";+ type GatewayProviderName,+} from "@/src/features/ai-gateway/server/provider/registry";+import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";import { signHmacSha256 } from "@/src/server/utils/hmac";diff --git a/web/src/__tests__/account-settings-sign-out-all-sessions.clienttest.tsx b/web/src/__tests__/account-settings-sign-out-all-sessions.clienttest.tsxindex 189d2a0027..713c3d0967 100644--- a/web/src/__tests__/account-settings-sign-out-all-sessions.clienttest.tsx+++ b/web/src/__tests__/account-settings-sign-out-all-sessions.clienttest.tsx@@ -79,7 +79,7 @@ vi.mock("@/src/utils/api", () => ({reportNonTrpcError: reportNonTrpcErrorMock,}));-import { useAccountSettingsPages } from "@/src/features/account";+import { useAccountSettingsPages } from "@/src/features/account/AccountSettingsPage";function AccountSettingsPage() {const [general] = useAccountSettingsPages();diff --git a/web/src/__tests__/aggregateScores.clienttest.ts b/web/src/__tests__/aggregateScores.clienttest.tsindex ca3dbb9366..54aac168df 100644--- a/web/src/__tests__/aggregateScores.clienttest.ts+++ b/web/src/__tests__/aggregateScores.clienttest.ts@@ -1,6 +1,9 @@// @vitest-environment node-import { aggregateScores, type ScoreToAggregate } from "@/src/features/scores";+import {+ aggregateScores,+ type ScoreToAggregate,+} from "@/src/features/scores/lib/aggregateScores";describe("aggregateScores", () => {it("should return an empty object for an empty array", () => {diff --git a/web/src/__tests__/buildStepData.clienttest.ts b/web/src/__tests__/buildStepData.clienttest.tsindex 1fe3b09f1a..79c559e592 100644--- a/web/src/__tests__/buildStepData.clienttest.ts+++ b/web/src/__tests__/buildStepData.clienttest.ts@@ -15,7 +15,7 @@ vi.mock("@langfuse/shared", () => ({}));import { buildStepData } from "@/src/features/trace-graph-view/buildStepData";-import { type AgentGraphDataResponse } from "@/src/features/trace-graph-view";+import type { AgentGraphDataResponse } from "@/src/features/trace-graph-view/types";describe("buildStepData", () => {const createMockObservation = (diff --git a/web/src/__tests__/detail-page-route-params.clienttest.tsx b/web/src/__tests__/detail-page-route-params.clienttest.tsxindex f6657f6a4b..6ad23da6f0 100644--- a/web/src/__tests__/detail-page-route-params.clienttest.tsx+++ b/web/src/__tests__/detail-page-route-params.clienttest.tsx@@ -26,7 +26,7 @@ vi.mock("@/src/features/events/hooks/useReadPath", () => ({useReadPath: () => ({ isV4: false, isResolved: true }),}));-vi.mock("@/src/features/widgets", () => ({+vi.mock("@/src/features/widgets/components/ConnectedWidgetForm", () => ({ConnectedWidgetForm: ({ projectId }: { projectId: string }) => (<div data-testid="widget-form">{projectId}</div>),@@ -96,8 +96,8 @@ vi.mock("@/src/features/datasets/components/DatasetRunsTable", () => ({),}));-vi.mock("@/src/features/experiments/components/table", () => ({- ExperimentsTable: ({ projectId }: { projectId: string }) => (+vi.mock("@/src/features/experiments/components/table/ExperimentsTable", () => ({+ default: ({ projectId }: { projectId: string }) => (<div data-testid="experiments-table">{projectId}</div>),}));diff --git a/web/src/__tests__/eventsTablePaths.clienttest.ts b/web/src/__tests__/eventsTablePaths.clienttest.tsindex 3639aec39d..a9afb04a3e 100644--- a/web/src/__tests__/eventsTablePaths.clienttest.ts+++ b/web/src/__tests__/eventsTablePaths.clienttest.ts@@ -3,7 +3,7 @@import {buildEventsTablePathForObservationType,buildEventsTablePathForSpanName,-} from "@/src/features/events";+} from "@/src/features/events/lib/eventsTablePaths";describe("buildEventsTablePathForSpanName", () => {it("opens the observations table with a name filter", () => {const result = buildEventsTablePathForSpanName({diff --git a/web/src/__tests__/mergeScoresWithCache.clienttest.ts b/web/src/__tests__/mergeScoresWithCache.clienttest.tsindex e8df7cff24..94e7468f9b 100644--- a/web/src/__tests__/mergeScoresWithCache.clienttest.ts+++ b/web/src/__tests__/mergeScoresWithCache.clienttest.ts@@ -4,9 +4,9 @@ import {mergeScoresWithCache,mergeAggregatesWithCache,mergeAnnotationScoresWithCache,- type CachedScore,- type AnnotationScore,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/mergeScoresWithCache";+import type { CachedScore } from "@/src/features/scores/contexts/ScoreCacheProvider";+import type { AnnotationScore } from "@/src/features/scores/types";import { type ScoreDomain, type ScoreAggregate } from "@langfuse/shared";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";diff --git a/web/src/__tests__/organization-settings-pages.clienttest.tsx b/web/src/__tests__/organization-settings-pages.clienttest.tsxindex 5468965d60..af4cf9900c 100644--- a/web/src/__tests__/organization-settings-pages.clienttest.tsx+++ b/web/src/__tests__/organization-settings-pages.clienttest.tsx@@ -1,11 +1,11 @@import { renderHook } from "@testing-library/react";import { useSession } from "next-auth/react";-import { useHasEntitlement, usePlan } from "@/src/features/entitlements";-import { useIsFeatureEnabled } from "@/src/features/feature-flags";-import { useQueryProjectOrOrganization } from "@/src/features/projects";-import { useHasOrganizationAccess } from "@/src/features/rbac";-import { useIsCloudBillingAvailable } from "@/src/ee/features/billing";+import { useHasEntitlement, usePlan } from "@/src/features/entitlements/hooks";+import { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";import { useV4UpgradeUiFlag } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { useOrganizationSettingsPages } from "@/src/features/organizations/OrganizationSettingsPage";import { env } from "@/src/env.mjs";@@ -56,16 +56,19 @@ vi.mock("@/src/ee/features/billing/components/BillingSettings", () => ({BillingSettings: () => null,}));-vi.mock("@/src/features/organization-usage", () => ({- OrganizationUsageBreakdown: () => null,-}));+vi.mock(+ "@/src/features/organization-usage/components/OrganizationUsageBreakdown",+ () => ({+ OrganizationUsageBreakdown: () => null,+ }),+);vi.mock("@/src/features/entitlements/hooks", () => ({useHasEntitlement: vi.fn(),usePlan: vi.fn(),}));-vi.mock("@/src/ee/features/sso-settings", () => ({+vi.mock("@/src/ee/features/sso-settings/components/SSOSettings", () => ({SSOSettings: () => null,}));@@ -90,7 +93,7 @@ vi.mock("@/src/ee/features/billing/utils/isCloudBilling", () => ({useIsCloudBillingAvailable: vi.fn(),}));-vi.mock("@/src/ee/features/audit-log-viewer", () => ({+vi.mock("@/src/ee/features/audit-log-viewer/OrgAuditLogsSettingsPage", () => ({OrgAuditLogsSettingsPage: () => null,}));@@ -122,13 +125,36 @@ vi.mock("@/src/utils/api", () => ({},}));-vi.mock("@/src/features/ai-gateway", () => ({- GatewayAnalyticsPage: () => null,- GatewayApiKeysPage: () => null,- GatewayModelsPage: () => null,- GatewayNotDeployedNotice: () => null,- GatewaySetupPage: () => null,-}));+vi.mock(+ "@/src/features/ai-gateway/components/GatewayAnalyticsPage/GatewayAnalyticsPage",+ () => ({+ GatewayAnalyticsPage: () => null,+ }),+);+vi.mock(+ "@/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage",+ () => ({+ GatewayApiKeysPage: () => null,+ }),+);+vi.mock(+ "@/src/features/ai-gateway/components/GatewayModelsPage/GatewayModelsPage",+ () => ({+ GatewayModelsPage: () => null,+ }),+);+vi.mock(+ "@/src/features/ai-gateway/components/GatewayNotDeployedNotice/GatewayNotDeployedNotice",+ () => ({+ GatewayNotDeployedNotice: () => null,+ }),+);+vi.mock(+ "@/src/features/ai-gateway/components/GatewaySetupPage/GatewaySetupPage",+ () => ({+ GatewaySetupPage: () => null,+ }),+);const organization = {id: "org-1",diff --git a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts b/web/src/__tests__/server/ai-gateway-control-plane.servertest.tsindex 21fc725d13..5e1f4ecf08 100644--- a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts+++ b/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts@@ -4,7 +4,7 @@ import { createHash, generateKeyPairSync, randomUUID } from "node:crypto";import type { Session } from "next-auth";import { afterEach, describe, expect, it, vi } from "vitest";import * as SharedServer from "@langfuse/shared/src/server";-import type * as BillingServer from "@/src/ee/features/billing/server";+import type * as BillingServer from "@/src/ee/features/billing/utils/isCloudBillingEnabled";import { z } from "zod/v4";const { addNotificationJobs, getNotificationJob } = vi.hoisted(() => ({@@ -36,11 +36,14 @@ const { isCloudBillingEnabled } = vi.hoisted(() => ({isCloudBillingEnabled: vi.fn<() => boolean>(),}));-vi.mock("@/src/ee/features/billing/server", async (importOriginal) => {- const actual = await importOriginal<typeof BillingServer>();- isCloudBillingEnabled.mockImplementation(actual.isCloudBillingEnabled);- return { ...actual, isCloudBillingEnabled };-});+vi.mock(+ "@/src/ee/features/billing/utils/isCloudBillingEnabled",+ async (importOriginal) => {+ const actual = await importOriginal<typeof BillingServer>();+ isCloudBillingEnabled.mockImplementation(actual.isCloudBillingEnabled);+ return { ...actual, isCloudBillingEnabled };+ },+);function queuedNotifications(): SharedServer.NotificationEventType[] {return addNotificationJobs.mock.calls.flatMap(([jobs]) =>@@ -49,7 +52,7 @@ function queuedNotifications(): SharedServer.NotificationEventType[] {}import { env } from "@/src/env.mjs";-import * as sfdc from "@/src/ee/features/sfdc-sync/server";+import * as sfdc from "@/src/ee/features/sfdc-sync/server/sfdcService";import { appRouter } from "@/src/server/api/root";import {createInnerTRPCContext,@@ -67,10 +70,8 @@ import { GatewayModelsService } from "@/src/features/ai-gateway/server/provider/import { GatewayApiKeyService } from "@/src/features/ai-gateway/server/apiKey/gatewayApiKeyService";import { GatewayConfigService } from "@/src/features/ai-gateway/server/config/gatewayConfigService";import { getGatewaySetupRedirect } from "@/src/features/ai-gateway/server/gatewaySetupRedirect";-import {- GatewayModelCatalogService,- GatewayProviderService,-} from "@/src/features/ai-gateway/server/provider";+import { GatewayModelCatalogService } from "@/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService";+import { GatewayProviderService } from "@/src/features/ai-gateway/server/provider/connection/gatewayProviderService";import { createEs256JwtVerifier } from "@/src/server/utils/jwt";import { prisma, Role } from "@langfuse/shared/src/db";import { decrypt, encrypt } from "@langfuse/shared/encryption";diff --git a/web/src/__tests__/server/apiKeyCacheInvalidation.servertest.ts b/web/src/__tests__/server/apiKeyCacheInvalidation.servertest.tsindex 6d5008d0a1..136c296dfe 100644--- a/web/src/__tests__/server/apiKeyCacheInvalidation.servertest.ts+++ b/web/src/__tests__/server/apiKeyCacheInvalidation.servertest.ts@@ -41,13 +41,16 @@ vi.mock("@langfuse/shared/topics/server", () => ({vi.mock("@/src/ee/features/billing/utils/isCloudBillingEnabled", () => ({isCloudBillingEnabled: () => false,}));-vi.mock("@/src/ee/features/billing/server", async (importOriginal) => {- const actual = (await importOriginal()) as Record<string, unknown>;- return {- ...actual,- isCloudBillingEnabled: () => false,- };-});+vi.mock(+ "@/src/ee/features/billing/utils/isCloudBillingEnabled",+ async (importOriginal) => {+ const actual = (await importOriginal()) as Record<string, unknown>;+ return {+ ...actual,+ isCloudBillingEnabled: () => false,+ };+ },+);import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";diff --git a/web/src/__tests__/server/audit-log-in-app-agent.servertest.ts b/web/src/__tests__/server/audit-log-in-app-agent.servertest.tsindex b389bb455f..89020efebd 100644--- a/web/src/__tests__/server/audit-log-in-app-agent.servertest.ts+++ b/web/src/__tests__/server/audit-log-in-app-agent.servertest.ts@@ -1,6 +1,6 @@import { randomUUID } from "crypto";import { afterEach, describe, expect, it, vi } from "vitest";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { prisma, AuditLogRecordType } from "@langfuse/shared/src/db";import { createApiKey } from "@langfuse/shared/src/server/auth/apiKeys";import { createOrgProjectAndApiKey } from "@langfuse/shared/src/server";diff --git a/web/src/__tests__/server/audit-log-license-gate.servertest.ts b/web/src/__tests__/server/audit-log-license-gate.servertest.tsindex 8204a601a9..e5a763ab90 100644--- a/web/src/__tests__/server/audit-log-license-gate.servertest.ts+++ b/web/src/__tests__/server/audit-log-license-gate.servertest.ts@@ -27,7 +27,7 @@ vi.mock("@/src/env.mjs", async (importOriginal) => {};});-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { prisma } from "@langfuse/shared/src/db";import { createApiKey } from "@langfuse/shared/src/server/auth/apiKeys";import {diff --git a/web/src/__tests__/server/audit-log-staging.servertest.ts b/web/src/__tests__/server/audit-log-staging.servertest.tsindex 33f700b31c..a70bd13c6d 100644--- a/web/src/__tests__/server/audit-log-staging.servertest.ts+++ b/web/src/__tests__/server/audit-log-staging.servertest.ts@@ -34,7 +34,7 @@ import {type AuditLogRecordInsertType,} from "@langfuse/shared/src/server";import { createApiKey } from "@langfuse/shared/src/server/auth/apiKeys";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {createDatasetItemForApi,deleteDatasetItemForApi,diff --git a/web/src/__tests__/server/dataset-item-media-references.servertest.ts b/web/src/__tests__/server/dataset-item-media-references.servertest.tsindex 638a37dd83..af4c2edff6 100644--- a/web/src/__tests__/server/dataset-item-media-references.servertest.ts+++ b/web/src/__tests__/server/dataset-item-media-references.servertest.ts@@ -22,7 +22,7 @@ import {} from "@langfuse/shared/src/server";import { v4 } from "uuid";import { env } from "@/src/env.mjs";-import { MediaContentType } from "@/src/features/media/server";+import { MediaContentType } from "@/src/features/media/validation";const projectId = "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a";const session: Session = {diff --git a/web/src/__tests__/server/dataset-service.servertest.ts b/web/src/__tests__/server/dataset-service.servertest.tsindex a5ac3729a6..81ab4cca66 100644--- a/web/src/__tests__/server/dataset-service.servertest.ts+++ b/web/src/__tests__/server/dataset-service.servertest.ts@@ -25,7 +25,7 @@ import {import {aggregateScores,composeAggregateScoreKey,-} from "@/src/features/scores/server";+} from "@/src/features/scores/lib/aggregateScores";const projectId = "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a";process.env.LANGFUSE_DATASET_SERVICE_READ_FROM_VERSIONED_IMPLEMENTATION =diff --git a/web/src/__tests__/server/evaluation-rules-public-api.servertest.ts b/web/src/__tests__/server/evaluation-rules-public-api.servertest.tsindex 4ccf22e21f..a4e1a5801e 100644--- a/web/src/__tests__/server/evaluation-rules-public-api.servertest.ts+++ b/web/src/__tests__/server/evaluation-rules-public-api.servertest.ts@@ -10,14 +10,15 @@ import {createCodeEvaluator,createEvaluationRule,} from "@/src/__tests__/server/stable-evaluation-public-api-test-utils";-import { EvaluatorService, RuleService } from "@/src/features/evals/server";+import { EvaluatorService } from "@/src/features/evals/v2/server/evaluators/evaluatorService";+import { RuleService } from "@/src/features/evals/v2/server/rules/ruleService";import {DeleteEvaluationRuleResponse,EvaluationRule,- Evaluator,ListEvaluationRulesResponse,- PublicApiError,-} from "@/src/features/public-api";+} from "@/src/features/public-api/types/evaluation/evaluationRules";+import { Evaluator } from "@/src/features/public-api/types/evaluation/evaluators";+import { PublicApiError } from "@/src/features/public-api/types/public-api-errors";const createLegacyRule = (projectId: string, name: string) =>prisma.evaluationRule.create({diff --git a/web/src/__tests__/server/evaluator-history-public-api.servertest.ts b/web/src/__tests__/server/evaluator-history-public-api.servertest.tsindex 2e06fbeb74..18be05667b 100644--- a/web/src/__tests__/server/evaluator-history-public-api.servertest.ts+++ b/web/src/__tests__/server/evaluator-history-public-api.servertest.ts@@ -11,7 +11,7 @@ import {import {Evaluator,ListEvaluatorVersionsResponse,-} from "@/src/features/public-api";+} from "@/src/features/public-api/types/evaluation/evaluators";describe("stable evaluator history public API", () => {it("lists evaluator version history", async () => {diff --git a/web/src/__tests__/server/evaluators-public-api.servertest.ts b/web/src/__tests__/server/evaluators-public-api.servertest.tsindex 2e96b46cf4..f2cfdced61 100644--- a/web/src/__tests__/server/evaluators-public-api.servertest.ts+++ b/web/src/__tests__/server/evaluators-public-api.servertest.ts@@ -11,15 +11,16 @@ import {createCodeEvaluator,createEvaluationRule,} from "@/src/__tests__/server/stable-evaluation-public-api-test-utils";-import { EvaluatorService, RuleService } from "@/src/features/evals/server";+import { EvaluatorService } from "@/src/features/evals/v2/server/evaluators/evaluatorService";+import { RuleService } from "@/src/features/evals/v2/server/rules/ruleService";import {DeleteEvaluatorResponse,Evaluator,ListEvaluatorsResponse,LlmAsJudgeEvaluator,- PublicApiError,-} from "@/src/features/public-api";-import { toApiReadMappings } from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/evaluation/evaluators";+import { PublicApiError } from "@/src/features/public-api/types/public-api-errors";+import { toApiReadMappings } from "@/src/features/public-api/server/evaluation/evaluationAdapters";describe("stable evaluators public API", () => {it("creates evaluators", async () => {diff --git a/web/src/__tests__/server/external-media-storage-service.servertest.ts b/web/src/__tests__/server/external-media-storage-service.servertest.tsindex c1c92454a9..7482d4922a 100644--- a/web/src/__tests__/server/external-media-storage-service.servertest.ts+++ b/web/src/__tests__/server/external-media-storage-service.servertest.ts@@ -10,7 +10,7 @@ import {StorageServiceFactory,} from "@langfuse/shared/src/server";-import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server";+import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server/service";vi.mock("@langfuse/shared/src/server", async () => {const actual = await vi.importActual("@langfuse/shared/src/server");diff --git a/web/src/__tests__/server/in-app-agent-api-route-auth.servertest.ts b/web/src/__tests__/server/in-app-agent-api-route-auth.servertest.tsindex 21a9bc2411..4031a2bb8d 100644--- a/web/src/__tests__/server/in-app-agent-api-route-auth.servertest.ts+++ b/web/src/__tests__/server/in-app-agent-api-route-auth.servertest.ts@@ -36,13 +36,16 @@ vi.mock("@/src/server/auth", () => ({getServerAuthSessionForRequest: authMocks.getServerAuthSessionForRequest,}));-vi.mock("@/src/features/entitlements/server", async (importOriginal) => {- const actual = (await importOriginal()) as Record<string, unknown>;- return {- ...actual,- hasEntitlement: entitlementMocks.hasEntitlement,- };-});+vi.mock(+ "@/src/features/entitlements/server/hasEntitlement",+ async (importOriginal) => {+ const actual = (await importOriginal()) as Record<string, unknown>;+ return {+ ...actual,+ hasEntitlement: entitlementMocks.hasEntitlement,+ };+ },+);describe("in-app agent public API route auth", () => {beforeEach(() => {diff --git a/web/src/__tests__/server/llm-api-key.servertest.ts b/web/src/__tests__/server/llm-api-key.servertest.tsindex 9545412d16..76151ad496 100644--- a/web/src/__tests__/server/llm-api-key.servertest.ts+++ b/web/src/__tests__/server/llm-api-key.servertest.ts@@ -10,7 +10,7 @@ vi.mock("@langfuse/shared/src/server", async () => {});import { testFeatureFlags } from "@/src/__tests__/fixtures/feature-flags";-import * as auditLogs from "@/src/features/audit-logs/server";+import * as auditLogs from "@/src/features/audit-logs/auditLog";import type { Session } from "next-auth";import { BEDROCK_USE_DEFAULT_CREDENTIALS, LLMAdapter } from "@langfuse/shared";import { env } from "@/src/env.mjs";diff --git a/web/src/__tests__/server/mcp-helpers.ts b/web/src/__tests__/server/mcp-helpers.tsindex fcb4e947e0..fc608474ec 100644--- a/web/src/__tests__/server/mcp-helpers.ts+++ b/web/src/__tests__/server/mcp-helpers.ts@@ -16,7 +16,7 @@ import {UserId,} from "@langfuse/shared/rbac";import type { ServerContext } from "@/src/features/mcp/types";-import { authenticator } from "@/src/features/apiKey/server";+import { authenticator } from "@/src/features/apiKey/authenticator";/*** Creates a complete MCP test setup including:diff --git a/web/src/__tests__/server/mcp-public-api-tools.servertest.ts b/web/src/__tests__/server/mcp-public-api-tools.servertest.tsindex e61e60a53b..657700aaf6 100644--- a/web/src/__tests__/server/mcp-public-api-tools.servertest.ts+++ b/web/src/__tests__/server/mcp-public-api-tools.servertest.ts@@ -51,46 +51,40 @@ import {import "@/src/features/mcp/server/bootstrap";import { config as mcpRouteConfig } from "@/src/pages/api/public/mcp";import { toolRegistry } from "@/src/features/mcp/server/registry";+import { handleCreateAnnotationQueue } from "@/src/features/mcp/server/annotationQueues/tools/createAnnotationQueue";+import { handleCreateAnnotationQueueAssignment } from "@/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueAssignment";+import { handleCreateAnnotationQueueItem } from "@/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueItem";+import { handleDeleteAnnotationQueueAssignment } from "@/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueAssignment";+import { handleDeleteAnnotationQueueItem } from "@/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueItem";+import { handleGetAnnotationQueue } from "@/src/features/mcp/server/annotationQueues/tools/getAnnotationQueue";+import { handleGetAnnotationQueueItem } from "@/src/features/mcp/server/annotationQueues/tools/getAnnotationQueueItem";+import { handleListAnnotationQueueItems } from "@/src/features/mcp/server/annotationQueues/tools/listAnnotationQueueItems";+import { handleListAnnotationQueues } from "@/src/features/mcp/server/annotationQueues/tools/listAnnotationQueues";+import { handleUpdateAnnotationQueueItem } from "@/src/features/mcp/server/annotationQueues/tools/updateAnnotationQueueItem";+import { handleCreateComment } from "@/src/features/mcp/server/comments/tools/createComment";+import { handleGetComment } from "@/src/features/mcp/server/comments/tools/getComment";+import { handleListComments } from "@/src/features/mcp/server/comments/tools/listComments";+import { handleBatchUpsertDatasetItems } from "@/src/features/mcp/server/datasets/tools/batchUpsertDatasetItems";+import { handleCreateDatasetRunItem } from "@/src/features/mcp/server/datasets/tools/createDatasetRunItem";+import { handleDeleteDatasetItem } from "@/src/features/mcp/server/datasets/tools/deleteDatasetItem";+import { handleDeleteDatasetRun } from "@/src/features/mcp/server/datasets/tools/deleteDatasetRun";+import { handleGetDataset } from "@/src/features/mcp/server/datasets/tools/getDataset";+import { handleGetDatasetItem } from "@/src/features/mcp/server/datasets/tools/getDatasetItem";+import { handleGetDatasetRun } from "@/src/features/mcp/server/datasets/tools/getDatasetRun";+import { handleListDatasetItems } from "@/src/features/mcp/server/datasets/tools/listDatasetItems";+import { handleListDatasetRunItems } from "@/src/features/mcp/server/datasets/tools/listDatasetRunItems";+import { handleListDatasetRuns } from "@/src/features/mcp/server/datasets/tools/listDatasetRuns";+import { handleListDatasets } from "@/src/features/mcp/server/datasets/tools/listDatasets";import {- handleCreateAnnotationQueue,- handleCreateAnnotationQueueAssignment,- handleCreateAnnotationQueueItem,- handleDeleteAnnotationQueueAssignment,- handleDeleteAnnotationQueueItem,- handleGetAnnotationQueue,- handleGetAnnotationQueueItem,- handleListAnnotationQueueItems,- handleListAnnotationQueues,- handleUpdateAnnotationQueueItem,-} from "@/src/features/mcp/server/annotationQueues/tools";-import {- handleCreateComment,- handleGetComment,- handleListComments,-} from "@/src/features/mcp/server/comments/tools";-import {- handleBatchUpsertDatasetItems,- handleCreateDatasetRunItem,- handleDeleteDatasetItem,- handleDeleteDatasetRun,- handleGetDataset,- handleGetDatasetItem,- handleGetDatasetRun,- handleListDatasetItems,- handleListDatasetRunItems,- handleListDatasetRuns,- handleListDatasets,handleUpsertDataset,- handleUpsertDatasetItem,upsertDatasetTool,-} from "@/src/features/mcp/server/datasets/tools";-import { handleGetHealth } from "@/src/features/mcp/server/health/tools";-import {- handleCreateModel,- handleDeleteModel,- handleGetModel,- handleListModels,-} from "@/src/features/mcp/server/models/tools";+} from "@/src/features/mcp/server/datasets/tools/upsertDataset";+import { handleUpsertDatasetItem } from "@/src/features/mcp/server/datasets/tools/upsertDatasetItem";+import { handleGetHealth } from "@/src/features/mcp/server/health/tools/getHealth";+import { handleCreateModel } from "@/src/features/mcp/server/models/tools/createModel";+import { handleDeleteModel } from "@/src/features/mcp/server/models/tools/deleteModel";+import { handleGetModel } from "@/src/features/mcp/server/models/tools/getModel";+import { handleListModels } from "@/src/features/mcp/server/models/tools/listModels";import { handleCreateScoreConfig } from "@/src/features/mcp/server/scores/tools/createScoreConfig";import { handleGetScoreConfig } from "@/src/features/mcp/server/scores/tools/getScoreConfig";import { handleListScoreConfigs } from "@/src/features/mcp/server/scores/tools/listScoreConfigs";diff --git a/web/src/__tests__/server/mcp-tools-read.servertest.ts b/web/src/__tests__/server/mcp-tools-read.servertest.tsindex a075a7e52e..b1d3043e65 100644--- a/web/src/__tests__/server/mcp-tools-read.servertest.ts+++ b/web/src/__tests__/server/mcp-tools-read.servertest.ts@@ -205,7 +205,7 @@ import {handleListLlmConnections,listLlmConnectionsTool,} from "@/src/features/mcp/server/llmConnections/tools/listLlmConnections";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";import { handleListSkills } from "@/src/features/mcp/server/skills/tools/listSkills";import { handleGetSkill } from "@/src/features/mcp/server/skills/tools/getSkill";import { handleLoadSkill } from "@/src/features/mcp/server/skills/tools/loadSkill";diff --git a/web/src/__tests__/server/mcp-tools-write.servertest.ts b/web/src/__tests__/server/mcp-tools-write.servertest.tsindex 3900456eb2..ea82b5bc55 100644--- a/web/src/__tests__/server/mcp-tools-write.servertest.ts+++ b/web/src/__tests__/server/mcp-tools-write.servertest.ts@@ -77,7 +77,7 @@ import {import { handleCreateTextPrompt } from "@/src/features/mcp/server/prompts/tools/createTextPrompt";import { handleCreateChatPrompt } from "@/src/features/mcp/server/prompts/tools/createChatPrompt";import { handleUpdatePromptLabels } from "@/src/features/mcp/server/prompts/tools/updatePromptLabels";-import { handleCreateAnnotationQueue } from "@/src/features/mcp/server/annotationQueues/tools";+import { handleCreateAnnotationQueue } from "@/src/features/mcp/server/annotationQueues/tools/createAnnotationQueue";import {createEvaluatorTool,handleCreateEvaluator,diff --git a/web/src/__tests__/server/media.servertest.ts b/web/src/__tests__/server/media.servertest.tsindex 10b7908372..9243a5afe7 100644--- a/web/src/__tests__/server/media.servertest.ts+++ b/web/src/__tests__/server/media.servertest.ts@@ -9,13 +9,16 @@ import { makeZodVerifiedAPICallSilent } from "@/src/__tests__/test-utils";import { env } from "@/src/env.mjs";import {createMediaUploadUrl,+ updateMediaUploadStatus,+} from "@/src/features/media/server/mediaService";+import {type GetMediaResponse,- GetMediaResponseSchema,type GetMediaUploadUrlResponse,+ GetMediaResponseSchema,GetMediaUploadUrlResponseSchema,MediaContentType,- updateMediaUploadStatus,-} from "@/src/features/media/server";+} from "@/src/features/media/validation";+import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";import {diff --git a/web/src/__tests__/server/memberships-api.servertest.ts b/web/src/__tests__/server/memberships-api.servertest.tsindex 34540e991f..43107b07c8 100644--- a/web/src/__tests__/server/memberships-api.servertest.ts+++ b/web/src/__tests__/server/memberships-api.servertest.ts@@ -10,10 +10,10 @@ import projectMembershipRoute from "@/src/pages/api/public/projects/[projectId]/import { env } from "@/src/env.mjs";import { createMocks } from "node-mocks-http";import { type NextApiRequest, type NextApiResponse } from "next";-import * as auditLogs from "@/src/features/audit-logs/server";-import { authenticator } from "@/src/features/apiKey/server";+import * as auditLogs from "@/src/features/audit-logs/auditLog";+import { authenticator } from "@/src/features/apiKey/authenticator";import { type AuthorizationContext } from "@/src/features/auth/policy/types";-import * as sfdc from "@/src/ee/features/sfdc-sync/server";+import * as sfdc from "@/src/ee/features/sfdc-sync/server/sfdcService";import {handleUpdateMembership,handleDeleteMembership,diff --git a/web/src/__tests__/server/onboarding-router.servertest.ts b/web/src/__tests__/server/onboarding-router.servertest.tsindex c0f7e1d750..fee3b39605 100644--- a/web/src/__tests__/server/onboarding-router.servertest.ts+++ b/web/src/__tests__/server/onboarding-router.servertest.ts@@ -5,8 +5,8 @@ import { env } from "@/src/env.mjs";import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";import { createProjectMembershipsOnSignup } from "@/src/features/auth/lib/createProjectMembershipsOnSignup";-import { V4_DEFAULT_ENABLED_FROM_AT } from "@/src/features/events/server";-import { createProjectRoute } from "@/src/features/setup";+import { V4_DEFAULT_ENABLED_FROM_AT } from "@/src/features/events/lib/v4Rollout";+import { createProjectRoute } from "@/src/features/setup/setupRoutes";import { prisma, Role } from "@langfuse/shared/src/db";const makeSession = ({diff --git a/web/src/__tests__/server/organization-feature-flags.servertest.ts b/web/src/__tests__/server/organization-feature-flags.servertest.tsindex 7f51ce67f0..26945b11d4 100644--- a/web/src/__tests__/server/organization-feature-flags.servertest.ts+++ b/web/src/__tests__/server/organization-feature-flags.servertest.ts@@ -5,7 +5,7 @@ import { randomUUID } from "node:crypto";import { Role, type Plan } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";import { env } from "@/src/env.mjs";-import { getFeaturePreviewOptOutFlag } from "@/src/features/feature-flags/server";+import { getFeaturePreviewOptOutFlag } from "@/src/features/feature-flags/utils";import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";diff --git a/web/src/__tests__/server/policy-auth.servertest.ts b/web/src/__tests__/server/policy-auth.servertest.tsindex 69cd5ff540..f2da57a6a9 100644--- a/web/src/__tests__/server/policy-auth.servertest.ts+++ b/web/src/__tests__/server/policy-auth.servertest.ts@@ -6,7 +6,7 @@ import {import { prisma } from "@langfuse/shared/src/db";import { OrganizationId, ProjectId } from "@langfuse/shared/rbac";-import { Authenticator } from "@/src/features/apiKey/server";+import { Authenticator } from "@/src/features/apiKey/authenticator";import { authorize } from "@/src/features/rbac/authorize";import { ApiAuthService } from "@/src/features/public-api/server/apiAuth";diff --git a/web/src/__tests__/server/projects-api.servertest.ts b/web/src/__tests__/server/projects-api.servertest.tsindex 8c64787a08..a329d4de35 100644--- a/web/src/__tests__/server/projects-api.servertest.ts+++ b/web/src/__tests__/server/projects-api.servertest.ts@@ -22,7 +22,7 @@ import { createMocks } from "node-mocks-http";import projectApiKeysHandler from "@/src/pages/api/public/projects/[projectId]/apiKeys";import projectApiKeyHandler from "@/src/pages/api/public/projects/[projectId]/apiKeys/[apiKeyId]";import projectByIdHandler from "@/src/pages/api/public/projects/[projectId]";-import { authenticator } from "@/src/features/apiKey/server";+import { authenticator } from "@/src/features/apiKey/authenticator";import { type AuthorizationContext } from "@/src/features/auth/policy/types";import {organizationApiKeyCreationSchema,diff --git a/web/src/__tests__/server/prompts.v1.servertest.ts b/web/src/__tests__/server/prompts.v1.servertest.tsindex 3995d45268..7a9c22ea56 100644--- a/web/src/__tests__/server/prompts.v1.servertest.ts+++ b/web/src/__tests__/server/prompts.v1.servertest.ts@@ -16,7 +16,7 @@ import {createOrgProjectAndApiKey,getObservationById,} from "@langfuse/shared/src/server";-import { createPromptForApi } from "@/src/features/prompts/server";+import { createPromptForApi } from "@/src/features/prompts/server/prompt-api-service";import handler from "@/src/pages/api/public/prompts";describe("/api/public/prompts API Endpoint", () => {diff --git a/web/src/__tests__/server/repositories/experiments-public-api-repository.servertest.ts b/web/src/__tests__/server/repositories/experiments-public-api-repository.servertest.tsindex c465143b56..1635444559 100644--- a/web/src/__tests__/server/repositories/experiments-public-api-repository.servertest.ts+++ b/web/src/__tests__/server/repositories/experiments-public-api-repository.servertest.ts@@ -14,7 +14,7 @@ import { env } from "@/src/env.mjs";import {listExperimentItemsForPublicApi,listExperimentsForPublicApi,-} from "@/src/features/experiments/server/public";+} from "@/src/features/experiments/server/public/service";import {queryExperimentItemsForPublicApi,queryExperimentSummariesForPublicApi,diff --git a/web/src/__tests__/server/shadowAuth.servertest.ts b/web/src/__tests__/server/shadowAuth.servertest.tsindex 267330e3b5..927f5ad47a 100644--- a/web/src/__tests__/server/shadowAuth.servertest.ts+++ b/web/src/__tests__/server/shadowAuth.servertest.ts@@ -22,7 +22,7 @@ import { assignRole } from "@langfuse/shared/rbac/server";import { env } from "@/src/env.mjs";import { authorize } from "@/src/features/rbac/authorize";-import { type ShadowAuthParams } from "@/src/features/public-api/server";+import type { ShadowAuthParams } from "@/src/features/public-api/server/shadowAuth";import { type AuthorizationContext } from "@/src/features/auth/policy/types";// The seam is imported dynamically so the authenticator singleton capturesdiff --git a/web/src/__tests__/server/stable-evaluation-public-api-test-utils.ts b/web/src/__tests__/server/stable-evaluation-public-api-test-utils.tsindex d6345f7d77..0f585d4574 100644--- a/web/src/__tests__/server/stable-evaluation-public-api-test-utils.ts+++ b/web/src/__tests__/server/stable-evaluation-public-api-test-utils.ts@@ -1,5 +1,6 @@import { makeZodVerifiedAPICall } from "@/src/__tests__/test-utils";-import { EvaluationRule, Evaluator } from "@/src/features/public-api";+import { EvaluationRule } from "@/src/features/public-api/types/evaluation/evaluationRules";+import { Evaluator } from "@/src/features/public-api/types/evaluation/evaluators";export const codeDefinition = (sourceCode: string) => ({type: "code" as const,diff --git a/web/src/__tests__/server/traces-trpc.servertest.ts b/web/src/__tests__/server/traces-trpc.servertest.tsindex d429a619aa..ea923fd474 100644--- a/web/src/__tests__/server/traces-trpc.servertest.ts+++ b/web/src/__tests__/server/traces-trpc.servertest.ts@@ -19,7 +19,7 @@ import {import waitForExpect from "wait-for-expect";import { randomUUID } from "crypto";import { env } from "@/src/env.mjs";-import { composeAggregateScoreKey } from "@/src/features/scores/server";+import { composeAggregateScoreKey } from "@/src/features/scores/lib/aggregateScores";import { BatchExportFileFormat, BatchTableNames } from "@langfuse/shared";describe("traces trpc", () => {diff --git a/web/src/__tests__/server/unit/ai-gateway-model-discovery.servertest.ts b/web/src/__tests__/server/unit/ai-gateway-model-discovery.servertest.tsindex add0f41c96..319ed4b658 100644--- a/web/src/__tests__/server/unit/ai-gateway-model-discovery.servertest.ts+++ b/web/src/__tests__/server/unit/ai-gateway-model-discovery.servertest.ts@@ -3,7 +3,7 @@ import type { PrismaClient } from "@langfuse/shared/src/db";import { encrypt } from "@langfuse/shared/encryption";import type { Redis } from "ioredis";-import { GatewayModelCatalogService } from "@/src/features/ai-gateway/server/provider";+import { GatewayModelCatalogService } from "@/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService";import { anthropicModelDiscoveryAdapter } from "@/src/features/ai-gateway/server/provider/models/adapters/anthropic";import { openAiModelDiscoveryAdapter } from "@/src/features/ai-gateway/server/provider/models/adapters/openAi";diff --git a/web/src/__tests__/server/unit/apiKey/authenticator.servertest.ts b/web/src/__tests__/server/unit/apiKey/authenticator.servertest.tsindex 3cedebbd8d..796d898209 100644--- a/web/src/__tests__/server/unit/apiKey/authenticator.servertest.ts+++ b/web/src/__tests__/server/unit/apiKey/authenticator.servertest.ts@@ -14,7 +14,7 @@ import {hashSecretKey,} from "@langfuse/shared/src/server";-import { Authenticator } from "@/src/features/apiKey/server";+import { Authenticator } from "@/src/features/apiKey/authenticator";import { AuthenticatorCache } from "@/src/features/apiKey/authenticatorCache";import {OrganizationRepository,diff --git a/web/src/__tests__/server/unit/assertToolAuthorized.servertest.ts b/web/src/__tests__/server/unit/assertToolAuthorized.servertest.tsindex 8914e02087..1813b3ce6e 100644--- a/web/src/__tests__/server/unit/assertToolAuthorized.servertest.ts+++ b/web/src/__tests__/server/unit/assertToolAuthorized.servertest.ts@@ -26,7 +26,8 @@ import type { ToolDefinition } from "@/src/features/mcp/core/define-tool";import {__dangerouslySkipAuthz,type ApiAction,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/server/enforceAuth";+import type { ServerContext } from "@/src/features/mcp/types";import { type Policy } from "@/src/features/rbac/types";import { type AuthorizationContext } from "@/src/features/auth/policy/types";diff --git a/web/src/__tests__/server/unit/batch-actions-comment-filter.servertest.ts b/web/src/__tests__/server/unit/batch-actions-comment-filter.servertest.tsindex d584647b28..c93cfaddab 100644--- a/web/src/__tests__/server/unit/batch-actions-comment-filter.servertest.ts+++ b/web/src/__tests__/server/unit/batch-actions-comment-filter.servertest.ts@@ -21,7 +21,7 @@ vi.mock("@langfuse/shared/src/server", async (importOriginal) => {};});-vi.mock("@/src/features/audit-logs/server", () => ({+vi.mock("@/src/features/audit-logs/auditLog", () => ({auditLog: vi.fn(),}));diff --git a/web/src/__tests__/server/unit/buildScoreFilters.servertest.ts b/web/src/__tests__/server/unit/buildScoreFilters.servertest.tsindex 846b3d2781..ea48119d6d 100644--- a/web/src/__tests__/server/unit/buildScoreFilters.servertest.ts+++ b/web/src/__tests__/server/unit/buildScoreFilters.servertest.ts@@ -11,7 +11,7 @@ vi.mock("@/src/features/public-api/server/scores", () => ({convertScoreToPublicApi: vi.fn((score) => score),}));-vi.mock("@/src/features/audit-logs/server", () => ({+vi.mock("@/src/features/audit-logs/auditLog", () => ({auditLog: vi.fn(),}));diff --git a/web/src/__tests__/server/unit/chb-project-events.servertest.ts b/web/src/__tests__/server/unit/chb-project-events.servertest.tsindex 60224eaa57..4dd127c89d 100644--- a/web/src/__tests__/server/unit/chb-project-events.servertest.ts+++ b/web/src/__tests__/server/unit/chb-project-events.servertest.ts@@ -57,7 +57,7 @@ import {backfillChbProjectEvents,emitChbProjectEvent,sendChbProjectEvent,-} from "@/src/ee/features/billing/server";+} from "@/src/ee/features/billing/server/chb/chbProjectEvents";import { logger } from "@langfuse/shared/src/server";const loggerError = vidiff --git a/web/src/__tests__/server/unit/chbBillingService.servertest.ts b/web/src/__tests__/server/unit/chbBillingService.servertest.tsindex 974794b23f..520e701323 100644--- a/web/src/__tests__/server/unit/chbBillingService.servertest.ts+++ b/web/src/__tests__/server/unit/chbBillingService.servertest.ts@@ -14,7 +14,7 @@ const mocks = vi.hoisted(() => ({vi.mock("@/src/env.mjs", () => ({ env: mocks.env }));-vi.mock("@/src/features/audit-logs/server", () => ({+vi.mock("@/src/features/audit-logs/auditLog", () => ({auditLog: mocks.auditLog,}));diff --git a/web/src/__tests__/server/unit/chbWebhookHandler.servertest.ts b/web/src/__tests__/server/unit/chbWebhookHandler.servertest.tsindex d7b4787373..1bd7978bdd 100644--- a/web/src/__tests__/server/unit/chbWebhookHandler.servertest.ts+++ b/web/src/__tests__/server/unit/chbWebhookHandler.servertest.ts@@ -54,7 +54,7 @@ vi.mock("@langfuse/shared/src/server", async (importOriginal) => {};});-vi.mock("@/src/features/audit-logs/server", () => ({+vi.mock("@/src/features/audit-logs/auditLog", () => ({auditLog: mocks.auditLog,}));diff --git a/web/src/__tests__/server/unit/cloudBillingRouter.servertest.ts b/web/src/__tests__/server/unit/cloudBillingRouter.servertest.tsindex 7063e5e9b7..432e92af9c 100644--- a/web/src/__tests__/server/unit/cloudBillingRouter.servertest.ts+++ b/web/src/__tests__/server/unit/cloudBillingRouter.servertest.ts@@ -13,19 +13,22 @@ vi.mock("@/src/ee/features/billing/server/resolveBillingService", () => ({resolveBillingService: mocks.resolveBillingService,}));-vi.mock("@/src/features/entitlements/server", async (importOriginal) => {- const actual = (await importOriginal()) as Record<string, unknown>;- return {- ...actual,- throwIfNoEntitlement: mocks.throwIfNoEntitlement,- };-});+vi.mock(+ "@/src/features/entitlements/server/hasEntitlement",+ async (importOriginal) => {+ const actual = (await importOriginal()) as Record<string, unknown>;+ return {+ ...actual,+ throwIfNoEntitlement: mocks.throwIfNoEntitlement,+ };+ },+);vi.mock("@/src/features/rbac/utils/checkOrganizationAccess", () => ({throwIfNoOrganizationAccess: mocks.throwIfNoOrganizationAccess,}));-vi.mock("@/src/features/audit-logs/server", () => ({+vi.mock("@/src/features/audit-logs/auditLog", () => ({auditLog: mocks.auditLog,}));diff --git a/web/src/__tests__/server/unit/create-authed-project-api-route-auth-errors.servertest.ts b/web/src/__tests__/server/unit/create-authed-project-api-route-auth-errors.servertest.tsindex 67692aa62b..f6f53749ba 100644--- a/web/src/__tests__/server/unit/create-authed-project-api-route-auth-errors.servertest.ts+++ b/web/src/__tests__/server/unit/create-authed-project-api-route-auth-errors.servertest.ts@@ -54,7 +54,7 @@ const {},}));-vi.mock("@/src/features/apiKey/server", () => ({+vi.mock("@/src/features/apiKey/authenticator", () => ({authenticator: { authenticate: mockAuthenticate },}));diff --git a/web/src/__tests__/server/unit/dashboard-widget-min-version.servertest.ts b/web/src/__tests__/server/unit/dashboard-widget-min-version.servertest.tsindex 133b4a8633..a63a0d6ebf 100644--- a/web/src/__tests__/server/unit/dashboard-widget-min-version.servertest.ts+++ b/web/src/__tests__/server/unit/dashboard-widget-min-version.servertest.ts@@ -2,7 +2,7 @@ import {normalizePublicDashboardWidgetInput,validatePublicDashboardWidgetInput,} from "@/src/features/widgets/server/public-dashboard-widget-service";-import { StructuredPublicApiError } from "@/src/features/public-api";+import { StructuredPublicApiError } from "@/src/features/public-api/types/structuredPublicApiError";import { env as sharedEnv } from "@langfuse/shared/src/env";const baseInput = {diff --git a/web/src/__tests__/server/unit/data-access-days.servertest.ts b/web/src/__tests__/server/unit/data-access-days.servertest.tsindex 316cc7d547..450dcf5a3a 100644--- a/web/src/__tests__/server/unit/data-access-days.servertest.ts+++ b/web/src/__tests__/server/unit/data-access-days.servertest.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";const NOW = new Date("2026-08-28T12:00:00.000Z");describe("clampToDataAccessDays", () => {diff --git a/web/src/__tests__/server/unit/events-transcript-access.servertest.ts b/web/src/__tests__/server/unit/events-transcript-access.servertest.tsindex e0de281131..3b078d66b8 100644--- a/web/src/__tests__/server/unit/events-transcript-access.servertest.ts+++ b/web/src/__tests__/server/unit/events-transcript-access.servertest.ts@@ -5,10 +5,8 @@ import { testFeatureFlags } from "@/src/__tests__/fixtures/feature-flags";import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";import { env } from "@/src/env.mjs";-import {- getFeaturePreviewOptOutFlag,- parseFlagsWithOrganizationDefaults,-} from "@/src/features/feature-flags/server";+import { getFeaturePreviewOptOutFlag } from "@/src/features/feature-flags/utils";+import { parseFlagsWithOrganizationDefaults } from "@/src/features/feature-flags/server/parseFlags";const mocks = vi.hoisted(() => ({getObservationsForTraceFromEventsTable: vi.fn(async () => ({diff --git a/web/src/__tests__/server/unit/feedback-service.servertest.ts b/web/src/__tests__/server/unit/feedback-service.servertest.tsindex eb9f71b312..54e730078e 100644--- a/web/src/__tests__/server/unit/feedback-service.servertest.ts+++ b/web/src/__tests__/server/unit/feedback-service.servertest.ts@@ -39,7 +39,7 @@ vi.mock("@/src/features/public-api/server/RateLimitService", () => ({import {isProductFeedbackAvailable,submitFeedback,-} from "@/src/features/feedback/server";+} from "@/src/features/feedback/server/FeedbackService";import { feedbackFeature } from "@/src/features/mcp/server/feedback";import { getMcpServerInstructions } from "@/src/features/mcp/server/mcpServer";import { PostFeedbackBody } from "@/src/features/public-api/types/feedback";diff --git a/web/src/__tests__/server/unit/getAuditRequestContext.servertest.ts b/web/src/__tests__/server/unit/getAuditRequestContext.servertest.tsindex 728dd017d6..8dc67d9601 100644--- a/web/src/__tests__/server/unit/getAuditRequestContext.servertest.ts+++ b/web/src/__tests__/server/unit/getAuditRequestContext.servertest.ts@@ -8,7 +8,7 @@ const mockEnv = vi.hoisted(() => ({vi.mock("@/src/env.mjs", () => mockEnv);-import { getAuditRequestContext } from "@/src/features/audit-logs/server";+import { getAuditRequestContext } from "@/src/features/audit-logs/server/getAuditRequestContext";describe("getAuditRequestContext client IP", () => {it.each([diff --git a/web/src/__tests__/server/unit/ingestion-write-mode.servertest.ts b/web/src/__tests__/server/unit/ingestion-write-mode.servertest.tsindex 97ed5de321..b763d4a4a7 100644--- a/web/src/__tests__/server/unit/ingestion-write-mode.servertest.ts+++ b/web/src/__tests__/server/unit/ingestion-write-mode.servertest.ts@@ -48,10 +48,13 @@ vi.mock(import("@/src/env.mjs"), async (importOriginal) => {};});-vi.mock(import("@/src/features/public-api/server"), async (importOriginal) => ({- ...(await importOriginal()),- shadowAuth,-}));+vi.mock(+ import("@/src/features/public-api/server/shadowAuth"),+ async (importOriginal) => ({+ ...(await importOriginal()),+ shadowAuth,+ }),+);vi.mock(import("@langfuse/shared/src/server"), async (importOriginal) => {const original = await importOriginal();diff --git a/web/src/__tests__/server/unit/mcp-calltool-error.servertest.ts b/web/src/__tests__/server/unit/mcp-calltool-error.servertest.tsindex c3d3d070cc..32205bafdc 100644--- a/web/src/__tests__/server/unit/mcp-calltool-error.servertest.ts+++ b/web/src/__tests__/server/unit/mcp-calltool-error.servertest.ts@@ -8,7 +8,7 @@ import { z } from "zod";import { defineTool } from "@/src/features/mcp/core/define-tool";import { createMcpServer } from "@/src/features/mcp/server/mcpServer";import { toolRegistry } from "@/src/features/mcp/server/registry";-import { __dangerouslySkipAuthz } from "@/src/features/public-api/server";+import { __dangerouslySkipAuthz } from "@/src/features/public-api/server/enforceAuth";import type { ServerContext } from "@/src/features/mcp/types";vi.mock("@/src/features/mcp/server/registry", () => ({diff --git a/web/src/__tests__/server/unit/mcp-define-tool.servertest.ts b/web/src/__tests__/server/unit/mcp-define-tool.servertest.tsindex 278ab15259..35f0951c36 100644--- a/web/src/__tests__/server/unit/mcp-define-tool.servertest.ts+++ b/web/src/__tests__/server/unit/mcp-define-tool.servertest.ts@@ -4,7 +4,7 @@ import { z } from "zod";import { isoDateTime } from "@langfuse/shared";import { mockServerContext } from "../mcp-helpers";-import { __dangerouslySkipAuthz } from "@/src/features/public-api/server";+import { __dangerouslySkipAuthz } from "@/src/features/public-api/server/enforceAuth";import { defineTool } from "../../../features/mcp/core/define-tool";import type { ServerContext } from "../../../features/mcp/types";diff --git a/web/src/__tests__/server/unit/mcp-v4-migration.servertest.ts b/web/src/__tests__/server/unit/mcp-v4-migration.servertest.tsindex 8bd702b116..bb2f14a60f 100644--- a/web/src/__tests__/server/unit/mcp-v4-migration.servertest.ts+++ b/web/src/__tests__/server/unit/mcp-v4-migration.servertest.ts@@ -4,7 +4,7 @@ const { getProjectV4MigrationData } = vi.hoisted(() => ({getProjectV4MigrationData: vi.fn(),}));-vi.mock("@/src/features/v4/server", () => ({+vi.mock("@/src/features/v4/server/v4TransitionService", () => ({getProjectV4MigrationData,}));diff --git a/web/src/__tests__/server/unit/onboardingService.servertest.ts b/web/src/__tests__/server/unit/onboardingService.servertest.tsindex 2426d5636f..04a21e3981 100644--- a/web/src/__tests__/server/unit/onboardingService.servertest.ts+++ b/web/src/__tests__/server/unit/onboardingService.servertest.ts@@ -2,7 +2,7 @@ const { auditLogMock } = vi.hoisted(() => ({auditLogMock: vi.fn(),}));-vi.mock("@/src/features/audit-logs/server", () => ({+vi.mock("@/src/features/audit-logs/auditLog", () => ({auditLog: auditLogMock,}));@@ -14,7 +14,7 @@ import {provisionStarterOrganizationForNewUser,resolveOnboardingRedirectTarget,type RealOrganizationMembership,-} from "@/src/features/onboarding/server";+} from "@/src/features/onboarding/server/onboardingService";type CompletionPrisma = Parameters<typeof completeSignupOnboardingdiff --git a/web/src/__tests__/server/unit/polymorphicValue.servertest.ts b/web/src/__tests__/server/unit/polymorphicValue.servertest.tsindex ea1ab01b58..70c485d7f5 100644--- a/web/src/__tests__/server/unit/polymorphicValue.servertest.ts+++ b/web/src/__tests__/server/unit/polymorphicValue.servertest.ts@@ -1,4 +1,4 @@-import { polymorphicValue } from "@/src/features/public-api/server/scores-api-v3";+import { polymorphicValueForV3 as polymorphicValue } from "@langfuse/shared/src/server";describe("polymorphicValue", () => {it.each([diff --git a/web/src/__tests__/server/unit/public-api/enforceAuth.servertest.ts b/web/src/__tests__/server/unit/public-api/enforceAuth.servertest.tsindex 55b02abbe4..bb6df35a35 100644--- a/web/src/__tests__/server/unit/public-api/enforceAuth.servertest.ts+++ b/web/src/__tests__/server/unit/public-api/enforceAuth.servertest.ts@@ -5,7 +5,7 @@ import { ForbiddenError, LangfuseNotFoundError } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";import { addUserToSpan, instrumentAsync } from "@langfuse/shared/src/server";-import { authenticator } from "@/src/features/apiKey/server";+import { authenticator } from "@/src/features/apiKey/authenticator";import { authorize } from "@/src/features/rbac/authorize";import {__dangerouslySkipAuthz,@@ -23,7 +23,7 @@ const { authSpan } = vi.hoisted(() => ({authSpan: { setAttribute: vi.fn() },}));-vi.mock("@/src/features/apiKey/server", () => ({+vi.mock("@/src/features/apiKey/authenticator", () => ({authenticator: { authenticate: vi.fn() },}));vi.mock("@/src/features/rbac/authorize", () => ({ authorize: vi.fn() }));diff --git a/web/src/__tests__/server/unit/public-api/shadowAuth.servertest.ts b/web/src/__tests__/server/unit/public-api/shadowAuth.servertest.tsindex ac3dfdd38a..5bcf24ce47 100644--- a/web/src/__tests__/server/unit/public-api/shadowAuth.servertest.ts+++ b/web/src/__tests__/server/unit/public-api/shadowAuth.servertest.ts@@ -55,7 +55,10 @@ vi.mock(}),);-import { shadowAuth, shadowAuthorize } from "@/src/features/public-api/server";+import {+ shadowAuth,+ shadowAuthorize,+} from "@/src/features/public-api/server/shadowAuth";import { authorizeBlobStorageRequest } from "@/src/features/blobstorage-integration/authorizeBlobStorageRequest";import { type AuthorizationContext } from "@/src/features/auth/policy/types";diff --git a/web/src/__tests__/server/unit/public-api/shadowAuthorize.servertest.ts b/web/src/__tests__/server/unit/public-api/shadowAuthorize.servertest.tsindex 4c8274c371..b5e78e1326 100644--- a/web/src/__tests__/server/unit/public-api/shadowAuthorize.servertest.ts+++ b/web/src/__tests__/server/unit/public-api/shadowAuthorize.servertest.ts@@ -20,11 +20,12 @@ vi.mock("@/src/features/public-api/server/shadowAuthDiff", () => ({shadowAuthDiff,}));+import { shadowAuthorize } from "@/src/features/public-api/server/shadowAuth";import {- shadowAuthorize,__dangerouslySkipAuthz,type ApiAction,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/server/enforceAuth";+import { type Prisma } from "@langfuse/shared/src/db";import { authorizeProtectedLabelMutation } from "@/src/features/prompts/server/utils/authorizeProtectedLabelMutation";import { type Policy } from "@/src/features/rbac/types";diff --git a/web/src/__tests__/server/unit/resolveBillingService.servertest.ts b/web/src/__tests__/server/unit/resolveBillingService.servertest.tsindex fda77b7db7..d4ef304f3b 100644--- a/web/src/__tests__/server/unit/resolveBillingService.servertest.ts+++ b/web/src/__tests__/server/unit/resolveBillingService.servertest.ts@@ -20,7 +20,7 @@ vi.mock("@/src/ee/features/billing/server/stripe/stripeBillingService", () => ({createBillingServiceFromContext: mocks.createBillingServiceFromContext,}));-import { resolveBillingService } from "@/src/ee/features/billing/server";+import { resolveBillingService } from "@/src/ee/features/billing/server/resolveBillingService";import { ChbBillingService } from "@/src/ee/features/billing/server/chb/chbBillingService";import { logger } from "@langfuse/shared/src/server";diff --git a/web/src/__tests__/server/unit/resolveFilterPrompt.servertest.ts b/web/src/__tests__/server/unit/resolveFilterPrompt.servertest.tsindex 54cf853401..13cff1024d 100644--- a/web/src/__tests__/server/unit/resolveFilterPrompt.servertest.ts+++ b/web/src/__tests__/server/unit/resolveFilterPrompt.servertest.ts@@ -1,11 +1,11 @@import { afterEach, describe, expect, it, vi } from "vitest";-vi.mock("@/src/features/natural-language-filters/server", () => ({+vi.mock("@/src/features/natural-language-filters/server/utils", () => ({getLangfuseClient: vi.fn(),}));import { logger } from "@langfuse/shared/src/server";-import { getLangfuseClient } from "@/src/features/natural-language-filters/server";+import { getLangfuseClient } from "@/src/features/natural-language-filters/server/utils";import {buildFieldCatalog,buildFilterSystemPrompt,diff --git a/web/src/__tests__/server/unit/scores-cursor-v3.servertest.ts b/web/src/__tests__/server/unit/scores-cursor-v3.servertest.tsindex 865139345c..88829d95be 100644--- a/web/src/__tests__/server/unit/scores-cursor-v3.servertest.ts+++ b/web/src/__tests__/server/unit/scores-cursor-v3.servertest.ts@@ -1,7 +1,7 @@import {EncodedScoresCursorV3,encodeCursorV3,-} from "@/src/features/public-api/types/scores";+} from "@langfuse/shared/src/server";describe("Scores v3 cursor", () => {it("encode → decode round-trip preserves v, lastTimestamp, lastId", () => {diff --git a/web/src/__tests__/server/unit/sfdc-sync.servertest.ts b/web/src/__tests__/server/unit/sfdc-sync.servertest.tsindex e20898c204..3d57e32067 100644--- a/web/src/__tests__/server/unit/sfdc-sync.servertest.ts+++ b/web/src/__tests__/server/unit/sfdc-sync.servertest.ts@@ -126,8 +126,8 @@ import {getSfdcService,resetSfdcServiceCacheForTests,toSfdcPlan,- syncOrgPlanChangeToSfdc,-} from "@/src/ee/features/sfdc-sync/server";+} from "@/src/ee/features/sfdc-sync/server/sfdcService";+import { syncOrgPlanChangeToSfdc } from "@/src/ee/features/sfdc-sync/server/planChangeSync";import { createProjectMembershipsOnSignup } from "@/src/features/auth/lib/createProjectMembershipsOnSignup";import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";diff --git a/web/src/__tests__/server/unit/skill-file-contents-get.servertest.ts b/web/src/__tests__/server/unit/skill-file-contents-get.servertest.tsindex 728e507720..d4f7cc5b59 100644--- a/web/src/__tests__/server/unit/skill-file-contents-get.servertest.ts+++ b/web/src/__tests__/server/unit/skill-file-contents-get.servertest.ts@@ -7,7 +7,7 @@ const { getFileContents, shadowAuth } = vi.hoisted(() => ({shadowAuth: vi.fn(),}));-vi.mock("@/src/features/skills/server", () => ({+vi.mock("@/src/features/skills/server/skill-service", () => ({SkillService: class {getFileContents = getFileContents;},@@ -23,18 +23,10 @@ vi.mock("@/src/features/public-api/server/RateLimitService", () => ({},}));-vi.mock("@/src/features/ai-gateway/server", () => ({+vi.mock("@/src/features/ai-gateway/server/auth/ingestionTokenVerifier", () => ({verifyGatewayIngestionAuthorization: vi.fn(),}));-vi.mock("@/src/features/public-api/server", async () => {- const { createAuthedProjectAPIRoute } =- await import("@/src/features/public-api/server/createAuthedProjectAPIRoute");- const { withMiddlewares } =- await import("@/src/features/public-api/server/withMiddlewares");- return { createAuthedProjectAPIRoute, withMiddlewares };-});-import handler from "@/src/pages/api/public/skills/files/content";import unstableHandler from "@/src/pages/api/public/unstable/skills/files/content";diff --git a/web/src/__tests__/server/unit/skill-router.servertest.ts b/web/src/__tests__/server/unit/skill-router.servertest.tsindex 5d6fcc11a1..3ae19fd5c3 100644--- a/web/src/__tests__/server/unit/skill-router.servertest.ts+++ b/web/src/__tests__/server/unit/skill-router.servertest.ts@@ -22,7 +22,7 @@ vi.mock("@/src/server/auth", () => ({ getServerAuthSession: vi.fn() }));vi.mock("@/src/features/posthog-analytics/server/backendActivity", () => ({recordBackendActivity: vi.fn().mockResolvedValue(undefined),}));-vi.mock("@/src/features/skills/server/index", () => ({+vi.mock("@/src/features/skills/server/skill-service", () => ({SkillService: class {get = mocks.get;getFileContents = mocks.getFileContents;diff --git a/web/src/__tests__/server/unit/skill-service.servertest.ts b/web/src/__tests__/server/unit/skill-service.servertest.tsindex 15b443626f..912830089f 100644--- a/web/src/__tests__/server/unit/skill-service.servertest.ts+++ b/web/src/__tests__/server/unit/skill-service.servertest.ts@@ -6,7 +6,7 @@ import type { PrismaClient } from "@langfuse/shared/src/db";import { OrganizationId, ProjectId, SystemRoleId } from "@langfuse/shared/rbac";import { type AuthorizationContext } from "@/src/features/auth/policy/types";import { SkillService } from "@/src/features/skills/server/skill-service";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";const queueAdd = vi.hoisted(() => vi.fn());vi.mock("@langfuse/shared/src/server", async (importOriginal) => {@@ -17,7 +17,7 @@ vi.mock("@langfuse/shared/src/server", async (importOriginal) => {};});-vi.mock("@/src/features/audit-logs/server", () => ({+vi.mock("@/src/features/audit-logs/auditLog", () => ({auditLog: vi.fn(),}));diff --git a/web/src/__tests__/server/unit/stripeBillingService.servertest.ts b/web/src/__tests__/server/unit/stripeBillingService.servertest.tsindex ab9f90fd10..9afdd55a89 100644--- a/web/src/__tests__/server/unit/stripeBillingService.servertest.ts+++ b/web/src/__tests__/server/unit/stripeBillingService.servertest.ts@@ -16,7 +16,7 @@ vi.mock("@/src/ee/features/billing/utils/stripe", () => ({stripeClient: undefined,}));-vi.mock("@/src/features/audit-logs/server", () => ({+vi.mock("@/src/features/audit-logs/auditLog", () => ({auditLog: mocks.auditLog,}));diff --git a/web/src/__tests__/server/unit/structured-public-api-error-contract.servertest.ts b/web/src/__tests__/server/unit/structured-public-api-error-contract.servertest.tsindex 02a98be4ae..d6b905d454 100644--- a/web/src/__tests__/server/unit/structured-public-api-error-contract.servertest.ts+++ b/web/src/__tests__/server/unit/structured-public-api-error-contract.servertest.ts@@ -5,7 +5,7 @@ import {createStructuredPublicApiRateLimitError,structuredPublicApiErrorContract,toStructuredPublicApiError,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/server/structuredPublicApiErrorContract";describe("structured public api error contract", () => {it("uses one contract marker", () => {diff --git a/web/src/__tests__/server/userAccount.servertest.ts b/web/src/__tests__/server/userAccount.servertest.tsindex 2349fa72b5..0eb3b0ff48 100644--- a/web/src/__tests__/server/userAccount.servertest.ts+++ b/web/src/__tests__/server/userAccount.servertest.ts@@ -10,10 +10,8 @@ import { OrganizationId, SystemRoleId, UserId } from "@langfuse/shared/rbac";import { env } from "@/src/env.mjs";import { appRouter } from "@/src/server/api/root";import { createInnerTRPCContext } from "@/src/server/api/trpc";-import {- getFeaturePreviewOptOutFlag,- INTERNAL_FEATURE_FLAG,-} from "@/src/features/feature-flags/server";+import { getFeaturePreviewOptOutFlag } from "@/src/features/feature-flags/utils";+import { INTERNAL_FEATURE_FLAG } from "@/src/features/feature-flags/available-flags";import { getSessionLoginAt } from "@/src/features/auth/lib/sessionExpiration";import { getAuthOptions } from "@/src/server/auth";diff --git a/web/src/__tests__/server/users-facet-coverage.servertest.ts b/web/src/__tests__/server/users-facet-coverage.servertest.tsindex 3b20dc7aea..a44658670a 100644--- a/web/src/__tests__/server/users-facet-coverage.servertest.ts+++ b/web/src/__tests__/server/users-facet-coverage.servertest.ts@@ -13,7 +13,7 @@*/import { randomUUID } from "crypto";-import { observationEventsFilterConfig } from "@/src/features/events/server";+import { observationEventsFilterConfig } from "@/src/features/events/config/filter-config";import { traceFilterConfig } from "@/src/features/filters/config/traces-config";import {usersEventsFilterConfig,diff --git a/web/src/__tests__/transformScores.clienttest.ts b/web/src/__tests__/transformScores.clienttest.tsindex 1cc4e0d37c..a59d8f8327 100644--- a/web/src/__tests__/transformScores.clienttest.ts+++ b/web/src/__tests__/transformScores.clienttest.ts@@ -1,6 +1,6 @@// @vitest-environment node-import { transformToAnnotationScores } from "@/src/features/scores";+import { transformToAnnotationScores } from "@/src/features/scores/lib/transformScores";import {type ScoreDomain,type ScoreAggregate,diff --git a/web/src/components/ActionButton.tsx b/web/src/components/ActionButton.tsxindex ba19f1e142..7cfc65938f 100644--- a/web/src/components/ActionButton.tsx+++ b/web/src/components/ActionButton.tsx@@ -4,7 +4,7 @@ import { Lock, AlertCircle, ExternalLink, Sparkle } from "@langfuse/icons";import { Button, type ButtonProps } from "@/src/components/ui/button";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";import Link from "next/link";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export type ActionButtonProps = Pick<ButtonProps,diff --git a/web/src/components/BatchExportTableButton.tsx b/web/src/components/BatchExportTableButton.tsxindex 3d2b5ad2fe..73a0c41517 100644--- a/web/src/components/BatchExportTableButton.tsx+++ b/web/src/components/BatchExportTableButton.tsx@@ -20,7 +20,7 @@ import {} from "@langfuse/shared";import React from "react";import { api } from "@/src/utils/api";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";export type BatchExportTableButtonProps = {projectId: string;diff --git a/web/src/components/ChatMessages/ChatMessageComponent.tsx b/web/src/components/ChatMessages/ChatMessageComponent.tsxindex 9c6e10f7d9..32ca5440de 100644--- a/web/src/components/ChatMessages/ChatMessageComponent.tsx+++ b/web/src/components/ChatMessages/ChatMessageComponent.tsx@@ -20,7 +20,7 @@ import {} from "@langfuse/shared";import { Button } from "@/src/components/ui/button";import { Card, CardContent } from "@/src/components/ui/card";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import type { MessagesContext } from "./types";import { useSortable } from "@dnd-kit/sortable";import { cn } from "@/src/utils/tailwind";@@ -37,7 +37,7 @@ import { useOptionalPlaygroundContext } from "@/src/features/playground/page/conimport {useOptionalMessageSearchActions,useOptionalMessageSearchPageId,-} from "./MessageSearch";+} from "@/src/components/ChatMessages/messageSearch/context";export type MessageRowRefs = {rowRef: RefObject<HTMLDivElement | null>;diff --git a/web/src/components/ChatMessages/MessageSearch.tsx b/web/src/components/ChatMessages/MessageSearch.tsxdeleted file mode 100644index 20685b316e..0000000000--- a/web/src/components/ChatMessages/MessageSearch.tsx+++ /dev/null@@ -1,9 +0,0 @@-export {- MessageSearchPageProvider,- MessageSearchProvider,- useMessageSearchActions,- useOptionalMessageSearchActions,- useOptionalMessageSearchPageId,- useSyncMessageSearchMessages,-} from "./messageSearch/context";-export { MessageSearchToolbar } from "./messageSearch/toolbar";diff --git a/web/src/components/ChatMessages/messageSearch/controller.clienttest.ts b/web/src/components/ChatMessages/messageSearch/controller.clienttest.tsindex 2bed675b77..915c83187e 100644--- a/web/src/components/ChatMessages/messageSearch/controller.clienttest.ts+++ b/web/src/components/ChatMessages/messageSearch/controller.clienttest.ts@@ -2,11 +2,11 @@ import { ChatMessageRole, ChatMessageType } from "@langfuse/shared";import {applyCodeMirrorSearchQuery,setActiveSearchMarkCodeMirrorRange,-} from "../../editor";+} from "@/src/components/editor/CodeMirrorEditor";import { createMessageSearchController } from "./controller";-vi.mock("../../editor", () => ({+vi.mock("@/src/components/editor/CodeMirrorEditor", () => ({applyCodeMirrorSearchQuery: vi.fn(),setActiveSearchMarkCodeMirrorRange: vi.fn(),unsetActiveSearchMarkCodeMirrorRange: vi.fn(),diff --git a/web/src/components/ChatMessages/messageSearch/controller.ts b/web/src/components/ChatMessages/messageSearch/controller.tsindex 8f4ffc9a53..6efb706936 100644--- a/web/src/components/ChatMessages/messageSearch/controller.ts+++ b/web/src/components/ChatMessages/messageSearch/controller.ts@@ -11,7 +11,7 @@ import {applyCodeMirrorSearchQuery,unsetActiveSearchMarkCodeMirrorRange,setActiveSearchMarkCodeMirrorRange,-} from "@/src/components/editor";+} from "@/src/components/editor/CodeMirrorEditor";type MessageSearchMatch = {key: string;diff --git a/web/src/components/EnvLabelBadge.tsx b/web/src/components/EnvLabelBadge.tsxindex 4690d9e12d..9c3d01fdcb 100644--- a/web/src/components/EnvLabelBadge.tsx+++ b/web/src/components/EnvLabelBadge.tsx@@ -1,7 +1,8 @@import {isRegionProduction,type CloudRegionName,-} from "@/src/features/organizations";+} from "@/src/features/organizations/cloudRegions";+import { BadgeShell } from "@/src/components/design-system/Badge/Badge";import { assertUnreachable } from "@/src/utils/types";import { useMemo } from "react";diff --git a/web/src/components/JSONSchemaEditor.tsx b/web/src/components/JSONSchemaEditor.tsxindex cc8e0c36b0..df810f42d7 100644--- a/web/src/components/JSONSchemaEditor.tsx+++ b/web/src/components/JSONSchemaEditor.tsx@@ -2,8 +2,8 @@import React from "react";import { ArrowUpRight } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";-import { CodeMirrorEditor } from "@/src/components/editor";-import { showErrorToast } from "@/src/features/notifications";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { assertUnreachable } from "@langfuse/shared";type JSONSchemaEditorMode = "json"; // Future: "json" | "builder"diff --git a/web/src/components/ModelParameters/LLMApiKeyComponent.tsx b/web/src/components/ModelParameters/LLMApiKeyComponent.tsxindex 2637f78166..8a297bfe52 100644--- a/web/src/components/ModelParameters/LLMApiKeyComponent.tsx+++ b/web/src/components/ModelParameters/LLMApiKeyComponent.tsx@@ -3,7 +3,7 @@ import Link from "next/link";import { Label } from "@/src/components/ui/label";import { api } from "@/src/utils/api";import { type UIModelParams } from "@langfuse/shared";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export const LLMApiKeyComponent = (p: {projectId: string;modelParams: UIModelParams;diff --git a/web/src/components/ModelParameters/index.tsx b/web/src/components/ModelParameters/index.tsxindex bed9e711e7..f32d002f7f 100644--- a/web/src/components/ModelParameters/index.tsx+++ b/web/src/components/ModelParameters/index.tsx@@ -13,7 +13,7 @@ import {} from "@/src/components/ui/select";import { Slider } from "@/src/components/ui/Slider";import { CreateLLMApiKeyDialog } from "@/src/features/public-api/components/CreateLLMApiKeyDialog";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { cn } from "@/src/utils/tailwind";import {@@ -35,7 +35,7 @@ import {TooltipTrigger,} from "@/src/components/ui/tooltip";import { FormDescription } from "@/src/components/ui/form";-import { CodeMirrorEditor } from "../editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { Switch } from "@/src/components/design-system/Switch/Switch";import { LLMApiKeyComponent } from "./LLMApiKeyComponent";diff --git a/web/src/components/OrganizationDropdownMenu/OrganizationDropdownMenu.tsx b/web/src/components/OrganizationDropdownMenu/OrganizationDropdownMenu.tsxindex 722cdf7c87..d67d0f3cbd 100644--- a/web/src/components/OrganizationDropdownMenu/OrganizationDropdownMenu.tsx+++ b/web/src/components/OrganizationDropdownMenu/OrganizationDropdownMenu.tsx@@ -3,7 +3,7 @@ import { PlusIcon, Settings } from "@langfuse/icons";import { type Session } from "next-auth";import { type ComponentProps, useMemo } from "react";import { env } from "@/src/env.mjs";-import { createOrganizationRoute } from "@/src/features/setup";+import { createOrganizationRoute } from "@/src/features/setup/setupRoutes";type Organization = NonNullable<Session["user"]>["organizations"][number];diff --git a/web/src/components/ProjectDropdownMenu/ProjectDropdownMenu.tsx b/web/src/components/ProjectDropdownMenu/ProjectDropdownMenu.tsxindex 2829cafe42..33f7660d56 100644--- a/web/src/components/ProjectDropdownMenu/ProjectDropdownMenu.tsx+++ b/web/src/components/ProjectDropdownMenu/ProjectDropdownMenu.tsx@@ -1,5 +1,5 @@import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";-import { createProjectRoute } from "@/src/features/setup";+import { createProjectRoute } from "@/src/features/setup/setupRoutes";import { PlusIcon, Settings } from "@langfuse/icons";import { type Session } from "next-auth";import { type ComponentProps, useMemo } from "react";diff --git a/web/src/components/PublishSessionSwitch.tsx b/web/src/components/PublishSessionSwitch.tsxindex a1f21062cb..10643f790a 100644--- a/web/src/components/PublishSessionSwitch.tsx+++ b/web/src/components/PublishSessionSwitch.tsx@@ -11,9 +11,9 @@ import {TooltipContent,TooltipTrigger,} from "@/src/components/ui/tooltip";-import { useReadPath } from "@/src/features/events";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { env } from "@/src/env.mjs";import { api } from "@/src/utils/api";import { copyTextToClipboard } from "@/src/utils/clipboard";diff --git a/web/src/components/SettingsTable/SettingsTable.tsx b/web/src/components/SettingsTable/SettingsTable.tsxindex b7cb9c5831..201f0a4589 100644--- a/web/src/components/SettingsTable/SettingsTable.tsx+++ b/web/src/components/SettingsTable/SettingsTable.tsx@@ -19,14 +19,12 @@ import { DataTableColumnVisibilityFilter } from "@/src/components/table/DataTablimport { type RowHeight } from "@/src/components/table/data-table-row-height-switch";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";import { Button } from "@/src/components/ui/button";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Rows3 } from "@langfuse/icons";import { type LangfuseColumnDef } from "@/src/components/table/types";import { cn } from "@/src/utils/tailwind";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";export type SettingsTableToolbarAction = ActionButtonProps extends infer TAction? TAction extends ActionButtonPropsdiff --git a/web/src/components/deleteButton.tsx b/web/src/components/deleteButton.tsxindex c384a54a78..3a77002e97 100644--- a/web/src/components/deleteButton.tsx+++ b/web/src/components/deleteButton.tsx@@ -10,11 +10,11 @@ import {import { Button, type ButtonProps } from "@/src/components/ui/button";import { LockIcon, TrashIcon } from "@langfuse/icons";import { IconOnlyButton } from "@/src/components/IconOnlyButton";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { type ProjectScope } from "@langfuse/shared";import { api } from "@/src/utils/api";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { showSuccessToast } from "@/src/features/notifications";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";export type DeleteButtonProps = {diff --git a/web/src/components/design-system/charts/ChartLegend.tsx b/web/src/components/design-system/charts/ChartLegend.tsxdeleted file mode 100644index 64f07e01e2..0000000000--- a/web/src/components/design-system/charts/ChartLegend.tsx+++ /dev/null@@ -1,4 +0,0 @@-export {- ChartLegend,- type ChartLegendItem,-} from "@/src/components/design-system/internal/charts/ChartLegend";diff --git a/web/src/components/design-system/table/columns/createTagsTableColumn.tsx b/web/src/components/design-system/table/columns/createTagsTableColumn.tsxindex 7e4b562953..4bd3747d80 100644--- a/web/src/components/design-system/table/columns/createTagsTableColumn.tsx+++ b/web/src/components/design-system/table/columns/createTagsTableColumn.tsx@@ -3,7 +3,7 @@ import { type RowData } from "@tanstack/react-table";import { Skeleton } from "@/src/components/ui/skeleton";import { useCompactRows } from "@/src/components/table/data-table-row-height-switch";-import { TagList } from "@/src/features/tag";+import { default as TagList } from "@/src/features/tag/components/TagList";import { cn } from "@/src/utils/tailwind";import {createTableColumn,diff --git a/web/src/components/design-system/table/components/IOTableCell/IOTableCell.tsx b/web/src/components/design-system/table/components/IOTableCell/IOTableCell.tsxindex dda7b218dc..e775e716a3 100644--- a/web/src/components/design-system/table/components/IOTableCell/IOTableCell.tsx+++ b/web/src/components/design-system/table/components/IOTableCell/IOTableCell.tsx@@ -19,7 +19,7 @@ import {type ReactNode,} from "react";import { ControlledHoverCard } from "@/src/components/design-system/ControlledHoverCard/ControlledHoverCard";-import { decodeUnicodeEscapesOnly } from "@/src/utils/unicode";+import { decodeUnicodeEscapesOnly } from "@langfuse/shared";import { EmptyValue } from "@/src/components/design-system/table/components/EmptyValue/EmptyValue";export type IOTableCellVariant = "default" | "input" | "output";diff --git a/web/src/components/editor/index.ts b/web/src/components/editor/index.tsdeleted file mode 100644index 3ef451a7c8..0000000000--- a/web/src/components/editor/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from "./CodeMirrorEditor";-export * from "./fileDropPaste";-export * from "./jsonMagicPaste";diff --git a/web/src/components/layouts/MobileTopBar.tsx b/web/src/components/layouts/MobileTopBar.tsxindex 3680d60d7a..7634a52cb4 100644--- a/web/src/components/layouts/MobileTopBar.tsx+++ b/web/src/components/layouts/MobileTopBar.tsx@@ -9,7 +9,7 @@ import { TopbarAccount } from "@/src/components/nav/TopbarAccount";import { InAppAiAgentButton } from "@/src/components/nav/InAppAiAgentButton";import { EnvLabelBadge } from "@/src/components/EnvLabelBadge";import { useEnvLabel } from "@/src/hooks/useEnvLabel";-import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent";+import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";/*** Slim mobile top chrome for the minimal-chrome shell: hamburger · centereddiff --git a/web/src/components/layouts/app-layout/AppLayout.tsx b/web/src/components/layouts/app-layout/AppLayout.tsxindex 8b4f3e2977..bbec673aaa 100644--- a/web/src/components/layouts/app-layout/AppLayout.tsx+++ b/web/src/components/layouts/app-layout/AppLayout.tsx@@ -14,7 +14,7 @@ import { useRouter } from "next/router";import { signOut, useSession } from "next-auth/react";import { signOutCleanly } from "@/src/features/auth/lib/signOut";import { clearV4BetaEnabledSentryTag } from "@/src/utils/sentryV4BetaTag";-import { useQueryProjectOrOrganization } from "@/src/features/projects";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";import { ErrorPage } from "@/src/components/error-page";// Layout variantsdiff --git a/web/src/components/layouts/app-layout/hooks/useFilteredNavigation.ts b/web/src/components/layouts/app-layout/hooks/useFilteredNavigation.tsindex 84c52ad4ff..e0de3a3787 100644--- a/web/src/components/layouts/app-layout/hooks/useFilteredNavigation.ts+++ b/web/src/components/layouts/app-layout/hooks/useFilteredNavigation.ts@@ -10,9 +10,9 @@ import {useV4MigrationNavItemProject,} from "@/src/features/v4-migration/V4MigrationNavItem";import type { Session } from "next-auth";-import { useEntitlements } from "@/src/features/entitlements";-import { useUiCustomization } from "@/src/ee/features/ui-customization";-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useEntitlements } from "@/src/features/entitlements/hooks";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { useForceV3Experience } from "@/src/features/v4-migration/useForceV3Experience";import {ROUTES,@@ -26,7 +26,7 @@ import type { NavigationFilterContext } from "../utils/navigationFilters.types";import { isPathActive } from "../utils/pathClassification";import { resolveRoutePathname } from "../utils/routePathname";import { api } from "@/src/utils/api";-import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";/** Organization type from user session (can be null when not in project/org context) */type Organization =diff --git a/web/src/components/layouts/app-layout/hooks/useLayoutMetadata.ts b/web/src/components/layouts/app-layout/hooks/useLayoutMetadata.tsindex 210c5a26b6..afebe51eb7 100644--- a/web/src/components/layouts/app-layout/hooks/useLayoutMetadata.ts+++ b/web/src/components/layouts/app-layout/hooks/useLayoutMetadata.ts@@ -4,7 +4,7 @@*/import { useMemo } from "react";-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { env } from "@/src/env.mjs";import type { NavigationItem } from "@/src/components/layouts/utilities/routes";diff --git a/web/src/components/layouts/app-layout/right-drawer/AppContentWithRightDrawer.tsx b/web/src/components/layouts/app-layout/right-drawer/AppContentWithRightDrawer.tsxindex f569bb456b..99dd2d7f66 100644--- a/web/src/components/layouts/app-layout/right-drawer/AppContentWithRightDrawer.tsx+++ b/web/src/components/layouts/app-layout/right-drawer/AppContentWithRightDrawer.tsx@@ -1,4 +1,4 @@-import { useSupportDrawer } from "@/src/features/support-chat";+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";import { useV4MigrationPanel } from "@/src/features/v4-migration/V4MigrationPanelProvider";import { type PropsWithChildren } from "react";import { useMediaQuery } from "react-responsive";diff --git a/web/src/components/layouts/app-layout/right-drawer/MobileRightDrawer.tsx b/web/src/components/layouts/app-layout/right-drawer/MobileRightDrawer.tsxindex 685ffe8960..5330878764 100644--- a/web/src/components/layouts/app-layout/right-drawer/MobileRightDrawer.tsx+++ b/web/src/components/layouts/app-layout/right-drawer/MobileRightDrawer.tsx@@ -5,7 +5,7 @@ import {DrawerHeader,DrawerTitle,} from "@/src/components/ui/drawer";-import { useSupportDrawer } from "@/src/features/support-chat";+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";import { SupportDrawer } from "@/src/features/support-chat/SupportDrawer";import { useV4MigrationPanel } from "@/src/features/v4-migration/V4MigrationPanelProvider";import { V4MigrationPanel } from "@/src/features/v4-migration/V4MigrationPanel";diff --git a/web/src/components/layouts/app-layout/utils/navigationFilters.ts b/web/src/components/layouts/app-layout/utils/navigationFilters.tsindex af921b51b1..da4cc8f52e 100644--- a/web/src/components/layouts/app-layout/utils/navigationFilters.ts+++ b/web/src/components/layouts/app-layout/utils/navigationFilters.ts@@ -5,7 +5,8 @@import { RouteGroup, type Route } from "@/src/components/layouts/routes";import type { NavigationFilterContext } from "./navigationFilters.types";-import { hasProjectAccess, hasOrganizationAccess } from "@/src/features/rbac";+import { hasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { hasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import type { Session } from "next-auth";import { isAdminOnlyFeaturePreviewFlag } from "@/src/features/feature-flags/available-flags";import { getContextualFeatureFlags } from "@/src/features/feature-flags/utils";diff --git a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsxindex be4260f214..c828f45ebc 100644--- a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx+++ b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx@@ -11,10 +11,8 @@ import {type PropsWithChildren,} from "react";import Head from "next/head";-import {- useInternalViewMode,- InternalViewModeDialog,-} from "@/src/features/feature-flags/internal-view-mode";+import { useInternalViewMode } from "@/src/features/feature-flags/hooks/useInternalViewMode";+import { InternalViewModeDialog } from "@/src/features/feature-flags/components/InternalViewModeDialog";import { useRouter, type NextRouter } from "next/router";import {SidebarProvider,@@ -25,17 +23,15 @@ import { AppSidebar } from "@/src/components/nav/AppSidebar/AppSidebar";import { SidebarPresenceProvider } from "@/src/components/nav/SidebarPresenceProvider";import { Toaster } from "@/src/components/ui/Toaster";import { Layer } from "@/src/components/design-system/Layer/Layer";-import {- VersionUpdateBanner,- useVersionUpdatePrompt,-} from "@/src/features/version-update";+import { VersionUpdateBanner } from "@/src/features/version-update/VersionUpdateBanner";+import { useVersionUpdatePrompt } from "@/src/features/version-update/useVersionUpdatePrompt";import { AppContentWithRightDrawer } from "../right-drawer/AppContentWithRightDrawer";import { ThemeToggle } from "@/src/features/theming/ThemeToggle";import {getAvailableCloudRegionOptions,getCloudRegionAuthUrl,- useLangfuseCloudRegion,-} from "@/src/features/organizations";+} from "@/src/features/organizations/cloudRegions";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import type { Session } from "next-auth";import type { NavigationItem } from "@/src/components/layouts/utilities/routes";import type { RouteGroup } from "@/src/components/layouts/routes";@@ -47,30 +43,26 @@ import {useV4UpgradeUiEnabled,useV4UpgradeUiFlag,} from "@/src/features/v4-migration/useV4UpgradeUiEnabled";-import { useUiCustomization } from "@/src/ee/features/ui-customization";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import { findCurrentInstance } from "@/src/ee/features/ui-customization/instanceLinks";import { api } from "@/src/utils/api";-import { usePlan } from "@/src/features/entitlements";+import { usePlan } from "@/src/features/entitlements/hooks";import { env } from "@/src/env.mjs";import useLocalStorage from "@/src/components/useLocalStorage";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useSession } from "next-auth/react";-import { useQueryProjectOrOrganization } from "@/src/features/projects";-import {- CustomerDataWarningBannerView,- getCustomerDataWarning,-} from "@/src/features/customer-data-warning";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { CustomerDataWarningBannerView } from "@/src/features/customer-data-warning/CustomerDataWarningBannerView";+import { getCustomerDataWarning } from "@/src/features/customer-data-warning/getCustomerDataWarning";import { accountSettingsPath } from "@/src/features/settings/accountSettingsPath";-import { useHasOrganizationAccess } from "@/src/features/rbac";-import {- PaymentBannerView,- usePaymentBanner,-} from "@/src/features/payment-banner";-import { useTopBannerHeight } from "@/src/features/top-banner";import {LegacyUiBanner,useLegacyUiBannerVisible,} from "@/src/features/v4-migration/LegacyUiBanner";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { PaymentBannerView } from "@/src/features/payment-banner/PaymentBannerView";+import { usePaymentBanner } from "@/src/features/payment-banner/PaymentBanner";+import { useTopBannerHeight } from "@/src/features/top-banner/useTopBannerHeight";const DISMISSED_SIDEBAR_NOTIFICATIONS_KEY = "dismissed-sidebar-notifications";@@ -86,9 +78,11 @@ const CommandMenu = dynamic(const PreviewDeploymentBanner = dynamic(() =>- import("@/src/features/preview-deployment-banner").then((mod) => ({- default: mod.PreviewDeploymentBanner,- })),+ import("@/src/features/preview-deployment-banner/PreviewDeploymentBanner").then(+ (mod) => ({+ default: mod.PreviewDeploymentBanner,+ }),+ ),{ssr: false,},diff --git a/web/src/components/layouts/breadcrumb.tsx b/web/src/components/layouts/breadcrumb.tsxindex a8f00d5fbd..649a8b9fd2 100644--- a/web/src/components/layouts/breadcrumb.tsx+++ b/web/src/components/layouts/breadcrumb.tsx@@ -13,9 +13,9 @@ import { env } from "@/src/env.mjs";import {useOrgProjectSwitchPaths,useQueryProjectOrOrganization,-} from "@/src/features/projects";+} from "@/src/features/projects/hooks";import { useSession } from "next-auth/react";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { isCloudPlan, planLabels } from "@langfuse/shared";import Link from "next/link";import { Badge } from "@/src/components/design-system/Badge/Badge";diff --git a/web/src/components/layouts/default-head/DefaultHead.tsx b/web/src/components/layouts/default-head/DefaultHead.tsxindex 11650f89fd..db02744c1c 100644--- a/web/src/components/layouts/default-head/DefaultHead.tsx+++ b/web/src/components/layouts/default-head/DefaultHead.tsx@@ -1,6 +1,6 @@import Head from "next/head";import { useRouter } from "next/router";-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { useLayoutMetadata } from "@/src/components/layouts/app-layout/hooks/useLayoutMetadata";import { getPageMetadata } from "./getPageMetadata";diff --git a/web/src/components/layouts/default-head/getPageMetadata.ts b/web/src/components/layouts/default-head/getPageMetadata.tsindex 44324e891b..ab32ce9482 100644--- a/web/src/components/layouts/default-head/getPageMetadata.ts+++ b/web/src/components/layouts/default-head/getPageMetadata.ts@@ -1,7 +1,7 @@import {type CloudRegionName,isRegionProduction,-} from "@/src/features/organizations";+} from "@/src/features/organizations/cloudRegions";/*** Every region serves the same sign-in page, and the sign-in page is reacheddiff --git a/web/src/components/layouts/doc-popup.tsx b/web/src/components/layouts/doc-popup.tsxindex 3194e03b05..7e317b1f5c 100644--- a/web/src/components/layouts/doc-popup.tsx+++ b/web/src/components/layouts/doc-popup.tsx@@ -2,7 +2,7 @@import { useState } from "react";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";import { ControlledHoverCard } from "@/src/components/design-system/ControlledHoverCard/ControlledHoverCard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { cn } from "@/src/utils/tailwind";import { ExternalLink, Info } from "@langfuse/icons";diff --git a/web/src/components/layouts/header.tsx b/web/src/components/layouts/header.tsxindex 060a67bb1c..c05da0b390 100644--- a/web/src/components/layouts/header.tsx+++ b/web/src/components/layouts/header.tsx@@ -2,7 +2,7 @@import Link from "next/link";import DocPopup from "@/src/components/layouts/doc-popup";import { Badge } from "@/src/components/design-system/Badge/Badge";-import { InternalFeatureBadge } from "@/src/features/feature-flags";+import { InternalFeatureBadge } from "@/src/features/feature-flags/components/InternalFeatureBadge";import {type Status,StatusBadge,diff --git a/web/src/components/layouts/page-header.tsx b/web/src/components/layouts/page-header.tsxindex 4445fa9aa0..d293b45b07 100644--- a/web/src/components/layouts/page-header.tsx+++ b/web/src/components/layouts/page-header.tsx@@ -8,7 +8,7 @@ import { PageHeaderControlsSlotTarget } from "@/src/components/layouts/page-headimport { InAppAiAgentButton } from "@/src/components/nav/InAppAiAgentButton";import { TopbarBrand } from "@/src/components/nav/TopbarBrand";import { useHasAppSidebar } from "@/src/components/nav/SidebarPresenceProvider";-import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent";+import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";import { SidebarTrigger } from "@/src/components/ui/sidebar";import {PageTabs,diff --git a/web/src/components/layouts/routes.tsx b/web/src/components/layouts/routes.tsxindex b330e8672a..59f98b3564 100644--- a/web/src/components/layouts/routes.tsx+++ b/web/src/components/layouts/routes.tsx@@ -26,24 +26,20 @@ import {import { type ReactNode } from "react";import { type Entitlement } from "@/src/features/entitlements/constants/entitlements";import { type Session } from "next-auth";-import {- hasOrganizationAccess,- type OrganizationScope,-} from "@/src/features/rbac";+import { hasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { type OrganizationScope } from "@langfuse/shared/rbac";import { SupportButton } from "@/src/components/nav/SupportButton";-import { V4SidebarToggle } from "@/src/features/events";+import { V4SidebarToggle } from "@/src/features/events/components/V4SidebarToggle";import { BookACallButton } from "@/src/components/nav/BookACallButton";import { SidebarMenuButton } from "@/src/components/ui/sidebar";import { KeyboardShortcut } from "@/src/components/design-system/KeyboardShortcut/KeyboardShortcut";import { useCommandMenu } from "@/src/features/command-k-menu/CommandMenuProvider";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { CloudStatusMenu } from "@/src/features/cloud-status-notification/components/CloudStatusMenu";import { type ProductModule } from "@/src/ee/features/ui-customization/productModuleSchema";import { matchesPathname } from "@/src/components/layouts/app-layout/utils/pathClassification";-import {- InternalFeatureBadge,- useInternalFeaturesEnabled,-} from "@/src/features/feature-flags";+import { InternalFeatureBadge } from "@/src/features/feature-flags/components/InternalFeatureBadge";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";export enum RouteSection {Main = "main",diff --git a/web/src/components/nav/AppSidebar/AppSidebar.tsx b/web/src/components/nav/AppSidebar/AppSidebar.tsxindex 388ee81c9d..1ebd416d84 100644--- a/web/src/components/nav/AppSidebar/AppSidebar.tsx+++ b/web/src/components/nav/AppSidebar/AppSidebar.tsx@@ -34,7 +34,7 @@ import {} from "@langfuse/icons";import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";import { SiGithub } from "@langfuse/icons/si";-import { VERSION } from "@/src/constants";+import { VERSION } from "@/src/constants/VERSION";import {DropdownMenu,DropdownMenuContent,@@ -62,7 +62,7 @@ import { OrganizationDropdownMenu } from "@/src/components/OrganizationDropdownMimport { ProjectDropdownMenu } from "@/src/components/ProjectDropdownMenu/ProjectDropdownMenu";import { assertUnreachable } from "@/src/utils/types";import { SIDEBAR_NOTIFICATIONS, type SidebarNotification } from "./utils";-import { useOrgProjectSwitchPaths } from "@/src/features/projects";+import { useOrgProjectSwitchPaths } from "@/src/features/projects/hooks";import {APP_SHELL_CHROME_ROW_CLASS,APP_SHELL_CHROME_ROW_TEST_ID,diff --git a/web/src/components/nav/BookACallButton.tsx b/web/src/components/nav/BookACallButton.tsxindex d81a84aded..e02f3ecd1d 100644--- a/web/src/components/nav/BookACallButton.tsx+++ b/web/src/components/nav/BookACallButton.tsx@@ -1,7 +1,7 @@import { CalendarDays } from "@langfuse/icons";import { SidebarMenuButton } from "@/src/components/ui/sidebar";import Link from "next/link";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export const BookACallButton = () => {const capture = usePostHogClientCapture();diff --git a/web/src/components/nav/InAppAiAgentButton.tsx b/web/src/components/nav/InAppAiAgentButton.tsxindex 16711e100b..869a664b21 100644--- a/web/src/components/nav/InAppAiAgentButton.tsx+++ b/web/src/components/nav/InAppAiAgentButton.tsx@@ -5,7 +5,8 @@ import { KeyboardShortcut } from "@/src/components/design-system/KeyboardShortcuimport {useInAppAiAgent,type InAppAgentEntryPoint,-} from "@/src/features/in-app-agent";+} from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import { HaloIcon } from "@/src/features/in-app-agent/components/HaloIcon";import { cn } from "@/src/utils/tailwind";diff --git a/web/src/components/nav/SupportButton.tsx b/web/src/components/nav/SupportButton.tsxindex 10ef0098b4..b1efd37fa9 100644--- a/web/src/components/nav/SupportButton.tsx+++ b/web/src/components/nav/SupportButton.tsx@@ -1,8 +1,8 @@import { LifeBuoy } from "@langfuse/icons";import { SidebarMenuButton, useSidebar } from "@/src/components/ui/sidebar";-import { useSupportDrawer } from "@/src/features/support-chat";+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";import { useV4MigrationPanel } from "@/src/features/v4-migration/V4MigrationPanelProvider";-import { useInAppAiAgent } from "@/src/features/in-app-agent";+import { useInAppAiAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";export const SupportButton = () => {const { setOpen: setSupportDrawerOpen } = useSupportDrawer();diff --git a/web/src/components/nav/TopbarAccount.tsx b/web/src/components/nav/TopbarAccount.tsxindex e62884a856..f416228655 100644--- a/web/src/components/nav/TopbarAccount.tsx+++ b/web/src/components/nav/TopbarAccount.tsx@@ -16,7 +16,7 @@ import {import { ThemeToggle } from "@/src/features/theming/ThemeToggle";import { useV4UpgradeUiFlag } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { cn } from "@/src/utils/tailwind";-import { useQueryProjectOrOrganization } from "@/src/features/projects";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";import { accountSettingsPath } from "@/src/features/settings/accountSettingsPath";/**diff --git a/web/src/components/nav/TopbarBrand.tsx b/web/src/components/nav/TopbarBrand.tsxindex 8dc94d8c84..7fdbee7e32 100644--- a/web/src/components/nav/TopbarBrand.tsx+++ b/web/src/components/nav/TopbarBrand.tsx@@ -3,7 +3,7 @@import { cn } from "@/src/utils/tailwind";import Link from "next/link";import { env } from "@/src/env.mjs";-import { useUiCustomization } from "@/src/ee/features/ui-customization";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import { PlusIcon } from "@langfuse/icons";import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/LangfuseIcon";diff --git a/web/src/components/onboarding/AnnotationQueuesOnboarding.tsx b/web/src/components/onboarding/AnnotationQueuesOnboarding.tsxindex 1471077e08..66de621059 100644--- a/web/src/components/onboarding/AnnotationQueuesOnboarding.tsx+++ b/web/src/components/onboarding/AnnotationQueuesOnboarding.tsx@@ -3,7 +3,7 @@ import {type ValueProposition,} from "@/src/components/ui/SplashScreen";import { ClipboardCheck, Users, BarChart4, GitMerge } from "@langfuse/icons";-import { CreateOrEditAnnotationQueueButton } from "@/src/features/annotation-queues";+import { CreateOrEditAnnotationQueueButton } from "@/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton";export function AnnotationQueuesOnboarding({projectId,diff --git a/web/src/components/onboarding/DatasetItemsOnboarding.tsx b/web/src/components/onboarding/DatasetItemsOnboarding.tsxindex 9981f0b218..e9211ebf8e 100644--- a/web/src/components/onboarding/DatasetItemsOnboarding.tsx+++ b/web/src/components/onboarding/DatasetItemsOnboarding.tsx@@ -12,8 +12,8 @@ import {} from "@/src/components/ui/dialog";import { CsvUploadDialog } from "@/src/features/datasets/components/CsvUploadDialog";import { NewDatasetItemForm } from "@/src/features/datasets/components/NewDatasetItemForm";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { cn } from "@/src/utils/tailwind";interface DatasetItemEntryPointRowProps {diff --git a/web/src/components/schemas/ChatMlSchema.ts b/web/src/components/schemas/ChatMlSchema.tsdeleted file mode 100644index 8ab49dfd95..0000000000--- a/web/src/components/schemas/ChatMlSchema.ts+++ /dev/null@@ -1,2 +0,0 @@-// Re-export from shared (moved to enable worker tests)-export { ChatMlMessageSchema, ChatMlArraySchema } from "@langfuse/shared";diff --git a/web/src/components/table/DataTable.stories.tsx b/web/src/components/table/DataTable.stories.tsxindex 3c8f092507..7ef269e873 100644--- a/web/src/components/table/DataTable.stories.tsx+++ b/web/src/components/table/DataTable.stories.tsx@@ -51,7 +51,7 @@ import {formatAsLabel,LevelSymbols,} from "@/src/components/ObservationLevelTag";-import { TagList } from "@/src/features/tag";+import { default as TagList } from "@/src/features/tag/components/TagList";import { BreakdownTooltip } from "@/src/features/traces/components/BreakdownTooltip";import { DropdownMenuItem } from "@/src/components/ui/dropdown-menu";import { numberFormatter, usdFormatter } from "@/src/utils/numbers";diff --git a/web/src/components/table/DataTableAIFilters.tsx b/web/src/components/table/DataTableAIFilters.tsxindex fd756da63d..06b0802158 100644--- a/web/src/components/table/DataTableAIFilters.tsx+++ b/web/src/components/table/DataTableAIFilters.tsx@@ -9,9 +9,9 @@ import {TooltipTrigger,} from "@/src/components/ui/tooltip";import { Info } from "@langfuse/icons";-import { useQueryProject } from "@/src/features/projects";+import { useQueryProject } from "@/src/features/projects/hooks";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";-import { AIFeaturesDisabledNotice } from "@/src/features/organizations";+import { AIFeaturesDisabledNotice } from "@/src/features/organizations/components/AIFeaturesDisabledNotice";import { api, reportNonTrpcError } from "@/src/utils/api";import { type FilterState } from "@langfuse/shared";diff --git a/web/src/components/table/DataTableColumnVisibilityFilter.tsx b/web/src/components/table/DataTableColumnVisibilityFilter.tsxindex 0d41f09404..74d63cf90a 100644--- a/web/src/components/table/DataTableColumnVisibilityFilter.tsx+++ b/web/src/components/table/DataTableColumnVisibilityFilter.tsx@@ -13,7 +13,7 @@ import {} from "@tanstack/react-table";import { ChevronDown, ChevronRight, Menu } from "@langfuse/icons";import { type LangfuseColumnDef } from "@/src/components/table/types";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import DocPopup from "@/src/components/layouts/doc-popup";import {closestCenter,diff --git a/web/src/components/table/DataTablePagination.tsx b/web/src/components/table/DataTablePagination.tsxindex 25a7189b6e..ac081c66cb 100644--- a/web/src/components/table/DataTablePagination.tsx+++ b/web/src/components/table/DataTablePagination.tsx@@ -15,7 +15,7 @@ import {SelectTrigger,SelectValue,} from "@/src/components/ui/select";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Spinner } from "@/src/components/design-system/Spinner/Spinner";import { Input } from "@/src/components/ui/input";import {diff --git a/web/src/components/table/data-table-column-visibility-filter.clienttest.tsx b/web/src/components/table/data-table-column-visibility-filter.clienttest.tsxindex ea4271f913..216a41d4f1 100644--- a/web/src/components/table/data-table-column-visibility-filter.clienttest.tsx+++ b/web/src/components/table/data-table-column-visibility-filter.clienttest.tsx@@ -2,10 +2,8 @@ import { StrictMode, useState } from "react";import { fireEvent, render, screen } from "@testing-library/react";import { type VisibilityState } from "@tanstack/react-table";import { DataTableColumnVisibilityFilter } from "@/src/components/table/DataTableColumnVisibilityFilter";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { LayerProvider } from "@/src/context/LayerContext/LayerContext";import { type LangfuseColumnDef } from "@/src/components/table/types";diff --git a/web/src/components/table/data-table-controls.tsx b/web/src/components/table/data-table-controls.tsxindex cc7d3a2db9..3bbc9aaa98 100644--- a/web/src/components/table/data-table-controls.tsx+++ b/web/src/components/table/data-table-controls.tsx@@ -66,7 +66,7 @@ import {InputCommandItem,InputCommandList,} from "@/src/components/ui/input-command";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Badge } from "@/src/components/design-system/Badge/Badge";import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";import { Button } from "@/src/components/ui/button";@@ -98,7 +98,7 @@ import {PopoverTrigger,} from "@/src/components/ui/popover";import { DataTableAIFilters } from "@/src/components/table/DataTableAIFilters";-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { type FilterState } from "@langfuse/shared";interface ControlsContextType {diff --git a/web/src/components/table/data-table-row-height-switch.tsx b/web/src/components/table/data-table-row-height-switch.tsxindex e449f3d525..95206d1c51 100644--- a/web/src/components/table/data-table-row-height-switch.tsx+++ b/web/src/components/table/data-table-row-height-switch.tsx@@ -10,7 +10,7 @@ import {DropdownMenuCheckboxItem,} from "@/src/components/ui/dropdown-menu";import useLocalStorage from "@/src/components/useLocalStorage";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Rows3, Rows2, Rows4 } from "@langfuse/icons";import {createContext,diff --git a/web/src/components/table/data-table-toolbar.clienttest.tsx b/web/src/components/table/data-table-toolbar.clienttest.tsxindex 85beb06a8c..b2f50061c3 100644--- a/web/src/components/table/data-table-toolbar.clienttest.tsx+++ b/web/src/components/table/data-table-toolbar.clienttest.tsx@@ -1,7 +1,7 @@import { act, fireEvent, render, screen } from "@testing-library/react";import { vi } from "vitest";import type { ColumnDefinition } from "@langfuse/shared";-import { ExperimentDisplaySettings } from "@/src/features/experiments";+import { ExperimentDisplaySettings } from "@/src/features/experiments/components/ExperimentDisplaySettings";import {DataTableToolbar,type MultiSelect,diff --git a/web/src/components/table/data-table-toolbar.tsx b/web/src/components/table/data-table-toolbar.tsxindex dd366a81ca..776d6a7329 100644--- a/web/src/components/table/data-table-toolbar.tsx+++ b/web/src/components/table/data-table-toolbar.tsx@@ -34,7 +34,7 @@ import {type CustomRowHeightControl,type RowHeight,} from "@/src/components/table/data-table-row-height-switch";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { TimeRangePicker } from "@/src/components/date-picker";import {type TimeRange,diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsxindex 1f4d225bf1..ae31e21dec 100644--- a/web/src/components/table/data-table.tsx+++ b/web/src/components/table/data-table.tsx@@ -44,7 +44,7 @@ import {TableHeader,TableRow,} from "@/src/components/ui/table";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { cn } from "@/src/utils/tailwind";import {type ColumnOrderState,diff --git a/web/src/components/table/peek.tsx b/web/src/components/table/peek.tsxindex f579f62909..5306750ad8 100644--- a/web/src/components/table/peek.tsx+++ b/web/src/components/table/peek.tsx@@ -6,7 +6,7 @@ import { Drawer, DrawerContent, DrawerTitle } from "@/src/components/ui/drawer";import { Separator } from "@/src/components/ui/separator";import { type LayerName } from "@/src/context/LayerContext/layers";import { type LangfuseItemType } from "@/src/components/ItemBadge";-import { type ListEntry } from "@/src/features/navigate-detail-pages";+import type { ListEntry } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { cn } from "@/src/utils/tailwind";import { memo, useCallback, useEffect, useState } from "react";import { useRouter } from "next/router";@@ -17,7 +17,7 @@ import { PeekTableStateProvider } from "@/src/components/table/peek/contexts/Peeimport { PeekHeader } from "@/src/components/table/peek/PeekHeader";import { usePeekPanelState } from "@/src/components/table/peek/usePeekPanelState";import { shouldIgnoreOutsideInteraction } from "@/src/utils/outside-interaction";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";// Peek view-mode URL param (also cleared by usePeekNavigation on close). When// `expanded`, the desktop peek widens to viewport − sidebar — shareable + back-able.diff --git a/web/src/components/table/peek/PeekHeader.tsx b/web/src/components/table/peek/PeekHeader.tsxindex e5286a5bd9..cfe42b5e19 100644--- a/web/src/components/table/peek/PeekHeader.tsx+++ b/web/src/components/table/peek/PeekHeader.tsx@@ -15,10 +15,8 @@ import {} from "@/src/components/ui/tooltip";import { type LangfuseItemType } from "@/src/components/ItemBadge";import { EntityTitle } from "@/src/components/EntityTitle";-import {- DetailPageNav,- type ListEntry,-} from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";+import type { ListEntry } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import {ExternalLink,Maximize2,diff --git a/web/src/components/table/peek/TablePeekViewEvaluatorConfigDetail.tsx b/web/src/components/table/peek/TablePeekViewEvaluatorConfigDetail.tsxindex aeaaf0f54c..4f289e63d1 100644--- a/web/src/components/table/peek/TablePeekViewEvaluatorConfigDetail.tsx+++ b/web/src/components/table/peek/TablePeekViewEvaluatorConfigDetail.tsx@@ -18,10 +18,10 @@ import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";import { DeleteEvalConfigButton } from "@/src/components/deleteButton";import { DeactivateEvalConfig } from "@/src/features/evals/components/DeactivateEvalConfig";import { Switch } from "@/src/components/design-system/Switch/Switch";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useState } from "react";import { cn } from "@/src/utils/tailwind";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { EvaluatorPausedCallout } from "@/src/features/evals/components/EvaluatorPausedCallout";import {diff --git a/web/src/components/table/peek/TablePeekViewExperimentItemDetail.tsx b/web/src/components/table/peek/TablePeekViewExperimentItemDetail.tsxindex ba95087d35..9d997c2356 100644--- a/web/src/components/table/peek/TablePeekViewExperimentItemDetail.tsx+++ b/web/src/components/table/peek/TablePeekViewExperimentItemDetail.tsx@@ -1,11 +1,9 @@import { useRouter } from "next/router";import { usePeekData } from "@/src/components/table/peek/hooks/usePeekData";-import { TraceDetailBody } from "@/src/features/traces";+import { TraceDetailBody } from "@/src/features/traces/components/TraceDetailBody";import { TablePeekView } from "@/src/components/table/peek";-import {- ExperimentPeekFooter,- useExperimentPeekNavigation,-} from "@/src/features/experiments";+import { ExperimentPeekFooter } from "@/src/features/experiments/components/ExperimentPeekFooter";+import { useExperimentPeekNavigation } from "@/src/features/experiments/hooks/useExperimentPeekNavigation";import { parseTraceTimestampFromQuery } from "@/src/fns/parseTraceTimestampFromQuery/parseTraceTimestampFromQuery";const PeekViewExperimentItemDetail = ({ projectId }: { projectId: string }) => {diff --git a/web/src/components/table/peek/TablePeekViewObservationDetail.tsx b/web/src/components/table/peek/TablePeekViewObservationDetail.tsxindex 992620c3af..b840955ebc 100644--- a/web/src/components/table/peek/TablePeekViewObservationDetail.tsx+++ b/web/src/components/table/peek/TablePeekViewObservationDetail.tsx@@ -3,7 +3,8 @@ import {shouldClosePeekAfterDelete,} from "@/src/components/table/peek";import { usePeekData } from "@/src/components/table/peek/hooks/usePeekData";-import { TraceDetailActions, TraceDetailBody } from "@/src/features/traces";+import { TraceDetailActions } from "@/src/features/traces/components/TraceDetailActions";+import { TraceDetailBody } from "@/src/features/traces/components/TraceDetailBody";import { resolvePeekTraceParams } from "@/src/components/table/peek/resolvePeekTraceParams";import { buildTracePath } from "@langfuse/shared";import { useRouter } from "next/router";diff --git a/web/src/components/table/peek/hooks/usePeekData.ts b/web/src/components/table/peek/hooks/usePeekData.tsindex ccac663ad1..60c265b334 100644--- a/web/src/components/table/peek/hooks/usePeekData.ts+++ b/web/src/components/table/peek/hooks/usePeekData.ts@@ -1,4 +1,4 @@-import { useTraceDetailData } from "@/src/features/traces";+import { useTraceDetailData } from "@/src/features/traces/hooks/useTraceDetailData";type UsePeekDataProps = {projectId: string;diff --git a/web/src/components/table/peek/hooks/usePeekNavigation.ts b/web/src/components/table/peek/hooks/usePeekNavigation.tsindex 38d8f8f124..40db929d33 100644--- a/web/src/components/table/peek/hooks/usePeekNavigation.ts+++ b/web/src/components/table/peek/hooks/usePeekNavigation.ts@@ -1,10 +1,10 @@import { getPathnameWithoutBasePath } from "@/src/utils/api";-import { type ListEntry } from "@/src/features/navigate-detail-pages";+import type { ListEntry } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useRouter } from "next/router";import { useCallback } from "react";import { urlSearchParamsToQuery } from "@/src/utils/navigation";import { resolvePeekTraceParams } from "@/src/components/table/peek/resolvePeekTraceParams";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";const PEEK_PARAM = "peek";// View-mode param shared with the peek component (cleared whenever the peek closes).diff --git a/web/src/components/table/resizable-filter-layout.tsx b/web/src/components/table/resizable-filter-layout.tsxindex b8d6dbd800..0ef64c605e 100644--- a/web/src/components/table/resizable-filter-layout.tsx+++ b/web/src/components/table/resizable-filter-layout.tsx@@ -12,7 +12,7 @@ import { X } from "@langfuse/icons";import { ResizableSplitLayout } from "@/src/components/ui/ResizableSplitLayout";import { Sheet, SheetContent, SheetTitle } from "@/src/components/ui/sheet";import { Button } from "@/src/components/ui/button";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {SearchBarDraftCacheContext,useSearchBarDraftCache,diff --git a/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx b/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsxindex d8a9edfdc5..6f00199cbe 100644--- a/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx+++ b/web/src/components/table/table-view-presets/components/data-table-view-presets-drawer.tsx@@ -71,11 +71,12 @@ import {import { useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { copyTextToClipboard } from "@/src/utils/clipboard";import { useUniqueNameValidation } from "@/src/hooks/useUniqueNameValidation";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useHasProjectAccess } from "@/src/features/rbac";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useDefaultViewMutations } from "../hooks/useDefaultViewMutations";import { summarizeTableViewPreset } from "../lib/viewPreview";import { TableViewPresetsButton } from "./TableViewPresetsButton";diff --git a/web/src/components/table/table-view-presets/hooks/useDefaultViewMutations.ts b/web/src/components/table/table-view-presets/hooks/useDefaultViewMutations.tsindex 2c1f9eec60..fbbb71c53e 100644--- a/web/src/components/table/table-view-presets/hooks/useDefaultViewMutations.ts+++ b/web/src/components/table/table-view-presets/hooks/useDefaultViewMutations.ts@@ -1,5 +1,6 @@import { api } from "@/src/utils/api";-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { type DefaultViewScope } from "@langfuse/shared/src/server";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts b/web/src/components/table/table-view-presets/hooks/useTableViewManager.tsindex 949afbebb9..c598df3d3a 100644--- a/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts+++ b/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts@@ -17,9 +17,9 @@ import {import useSessionStorage from "@/src/components/useSessionStorage";import { useKeyedSessionStorageState } from "@/src/features/filters/hooks/useKeyedSessionStorageState";import { type LangfuseColumnDef } from "@/src/components/table/types";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import isEqual from "lodash/isEqual";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { validateOrderBy, validateFilters } from "../validation";import { isSystemPresetId } from "../components/data-table-view-presets-drawer";import type { FilterStateMigration } from "@/src/features/filters/lib/filter-config";diff --git a/web/src/components/table/table-view-presets/hooks/useViewMutations.ts b/web/src/components/table/table-view-presets/hooks/useViewMutations.tsindex cbc1efad29..52a38a5b55 100644--- a/web/src/components/table/table-view-presets/hooks/useViewMutations.ts+++ b/web/src/components/table/table-view-presets/hooks/useViewMutations.ts@@ -1,4 +1,5 @@-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { api } from "@/src/utils/api";import { copyTextToClipboard } from "@/src/utils/clipboard";import type { TableViewPresetState } from "@langfuse/shared";diff --git a/web/src/components/ui/CodeJsonViewer.tsx b/web/src/components/ui/CodeJsonViewer.tsxindex 4603a751f9..397888e0a9 100644--- a/web/src/components/ui/CodeJsonViewer.tsx+++ b/web/src/components/ui/CodeJsonViewer.tsx@@ -10,7 +10,7 @@ import { deepParseJson } from "@langfuse/shared";import { decodeUnicodeInJson } from "@/src/utils/decodeUnicodeInJson";import { Skeleton } from "@/src/components/ui/skeleton";import { useTheme } from "next-themes";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";import { LangfuseMediaView } from "@/src/components/ui/LangfuseMediaView";import { classifyMediaValue } from "@/src/components/ui/media/mediaUtils";import { MediaReferenceTag } from "@/src/components/ui/media/MediaReferenceTag";diff --git a/web/src/components/ui/JsonViewController.tsx b/web/src/components/ui/JsonViewController.tsxindex 1790cc0459..38f6ba6193 100644--- a/web/src/components/ui/JsonViewController.tsx+++ b/web/src/components/ui/JsonViewController.tsx@@ -8,11 +8,10 @@ import {useCallback,} from "react";import { type ExpandedState } from "@tanstack/react-table";-import { deepParseJson } from "@langfuse/shared";+import { deepParseJson, ChatMlArraySchema } from "@langfuse/shared";import { decodeUnicodeInJson } from "@/src/utils/decodeUnicodeInJson";-import { type MediaReturnType } from "@/src/features/media";+import { type MediaReturnType } from "@/src/features/media/validation";import { copyTextToClipboard } from "@/src/utils/clipboard";-import { ChatMlArraySchema } from "@/src/components/schemas/ChatMlSchema";import {filterAlreadyRenderedMedia,getRenderedInlineMediaIds,diff --git a/web/src/components/ui/LangfuseMediaView.tsx b/web/src/components/ui/LangfuseMediaView.tsxindex 16662b5175..d5da7bc13e 100644--- a/web/src/components/ui/LangfuseMediaView.tsx+++ b/web/src/components/ui/LangfuseMediaView.tsx@@ -13,8 +13,8 @@ import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import {type MediaContentType,type MediaReturnType,- mediaUrlQueryOptions,-} from "@/src/features/media";+} from "@/src/features/media/validation";+import { mediaUrlQueryOptions } from "@/src/features/media/constants/mediaUrlQueryOptions";import { MediaReferenceTag } from "@/src/components/ui/media/MediaReferenceTag";import { MediaFileView } from "@/src/components/ui/media/MediaFileView";diff --git a/web/src/components/ui/LargeStringFallback.tsx b/web/src/components/ui/LargeStringFallback.tsxindex 0737ee99ac..059eeffcb9 100644--- a/web/src/components/ui/LargeStringFallback.tsx+++ b/web/src/components/ui/LargeStringFallback.tsx@@ -3,7 +3,7 @@ import { Download } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";import { compactNumberFormatter } from "@/src/utils/numbers";import { LARGE_STRING_PREVIEW_CHARS } from "@/src/components/ui/largeStringGate";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { decodeUnicodeInJson } from "@/src/utils/decodeUnicodeInJson";/**diff --git a/web/src/components/ui/MarkdownJsonView.tsx b/web/src/components/ui/MarkdownJsonView.tsxindex 8aaab0fec1..3055ed2758 100644--- a/web/src/components/ui/MarkdownJsonView.tsx+++ b/web/src/components/ui/MarkdownJsonView.tsx@@ -7,7 +7,7 @@ import {import { Button } from "@/src/components/ui/button";import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";import { MarkdownView } from "@/src/components/ui/MarkdownView";-import { type MediaReturnType } from "@/src/features/media";+import { type MediaReturnType } from "@/src/features/media/validation";import { Check, Copy } from "@langfuse/icons";import { useMemo, useState } from "react";import { type z } from "zod";diff --git a/web/src/components/ui/MarkdownView.clienttest.tsx b/web/src/components/ui/MarkdownView.clienttest.tsxindex c4f9210a27..1cc710aed1 100644--- a/web/src/components/ui/MarkdownView.clienttest.tsx+++ b/web/src/components/ui/MarkdownView.clienttest.tsx@@ -42,8 +42,8 @@ vi.mock("@/src/utils/api", () => ({},}));-vi.mock("@/src/features/feature-flags", () => ({- useIsFeatureEnabled: () => true,+vi.mock("@/src/features/feature-flags/hooks/useIsFeatureEnabled", () => ({+ default: () => true,}));const renderMarkdown = (markdown: string) =>diff --git a/web/src/components/ui/MarkdownViewController.tsx b/web/src/components/ui/MarkdownViewController.tsxindex 682c10738f..9178f63734 100644--- a/web/src/components/ui/MarkdownViewController.tsx+++ b/web/src/components/ui/MarkdownViewController.tsx@@ -5,7 +5,7 @@ import {isOpenAITextContentPart,} from "@langfuse/shared";import { type z } from "zod";-import { type MediaReturnType } from "@/src/features/media";+import { type MediaReturnType } from "@/src/features/media/validation";import { copyTextToClipboard } from "@/src/utils/clipboard";import {filterAlreadyRenderedMedia,diff --git a/web/src/components/ui/PrettyJsonView.stories.tsx b/web/src/components/ui/PrettyJsonView.stories.tsxindex e6ddab540d..5fc0ce0446 100644--- a/web/src/components/ui/PrettyJsonView.stories.tsx+++ b/web/src/components/ui/PrettyJsonView.stories.tsx@@ -8,8 +8,10 @@ import { createTRPCClient, TRPCClientError } from "@trpc/client";import { observable } from "@trpc/server/observable";import { type AppRouter } from "@/src/server/api/root";import { api } from "@/src/utils/api";-import { MediaContentType } from "@/src/features/media";-import { MediaEnabledFields } from "@/src/features/media/validation";+import {+ MediaContentType,+ MediaEnabledFields,+} from "@/src/features/media/validation";import { MarkdownRenderCharacterLimitContext } from "@/src/components/MarkdownRenderCharacterLimitProvider/MarkdownRenderCharacterLimitContext";import { JsonViewController } from "./JsonViewController";import { IOSection } from "./IOSection";diff --git a/web/src/components/ui/markdown-media.utils.ts b/web/src/components/ui/markdown-media.utils.tsindex 18c54c33ba..5734633693 100644--- a/web/src/components/ui/markdown-media.utils.ts+++ b/web/src/components/ui/markdown-media.utils.ts@@ -8,7 +8,7 @@ import {type OpenAIOutputAudioType,type ParsedMediaReferenceType,} from "@langfuse/shared";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";import { type z } from "zod";const getMediaReferenceId = (diff --git a/web/src/components/ui/media/ExternalMediaView.tsx b/web/src/components/ui/media/ExternalMediaView.tsxindex cc47e88081..5dc89408e0 100644--- a/web/src/components/ui/media/ExternalMediaView.tsx+++ b/web/src/components/ui/media/ExternalMediaView.tsx@@ -1,6 +1,6 @@import { Skeleton } from "@/src/components/ui/skeleton";-import { useIsFeatureEnabled } from "@/src/features/feature-flags";-import { type MediaContentType } from "@/src/features/media";+import { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";+import type { MediaContentType } from "@/src/features/media/validation";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { MediaFileView } from "./MediaFileView";import { type MediaDescriptor } from "./mediaUtils";diff --git a/web/src/components/ui/media/MediaFileView.tsx b/web/src/components/ui/media/MediaFileView.tsxindex afa79dcea5..7178cbde8e 100644--- a/web/src/components/ui/media/MediaFileView.tsx+++ b/web/src/components/ui/media/MediaFileView.tsx@@ -7,7 +7,7 @@ import {COMPACT_IMAGE_MAX_HEIGHT_REM,ResizableImage,} from "@/src/components/ui/ResizableImage";-import { type MediaContentType } from "@/src/features/media";+import type { MediaContentType } from "@/src/features/media/validation";import { cn } from "@/src/utils/tailwind";export type MediaFileViewProps = {diff --git a/web/src/components/ui/media/MediaReferenceTag.tsx b/web/src/components/ui/media/MediaReferenceTag.tsxindex 3245bc2cb2..c49528987c 100644--- a/web/src/components/ui/media/MediaReferenceTag.tsx+++ b/web/src/components/ui/media/MediaReferenceTag.tsx@@ -3,9 +3,9 @@ import { useResolvedMedia } from "./useResolvedMedia";import { useResolvedExternalMedia } from "./useResolvedExternalMedia";import { type MediaDescriptor } from "./mediaUtils";import { OBSERVATION_FIELD_SIZE_LIMIT_MEDIA_SOURCE } from "@langfuse/shared";-import { useIsFeatureEnabled } from "@/src/features/feature-flags";+import { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";-import { useMediaPeek } from "@/src/features/media";+import { useMediaPeek } from "@/src/features/media/hooks/useMediaPeek";type LangfuseRefDescriptor = Extract<MediaDescriptor, { kind: "langfuseRef" }>;type S3Descriptor = Extract<MediaDescriptor, { kind: "s3" }>;diff --git a/web/src/components/ui/media/useResolvedExternalMedia.ts b/web/src/components/ui/media/useResolvedExternalMedia.tsindex f6b5619639..ee2146dd47 100644--- a/web/src/components/ui/media/useResolvedExternalMedia.ts+++ b/web/src/components/ui/media/useResolvedExternalMedia.ts@@ -1,6 +1,6 @@import { api } from "@/src/utils/api";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";-import { getSignedUrlState } from "@/src/features/media";+import { getSignedUrlState } from "@/src/features/media/fns/getSignedUrlState";import { type MediaDescriptor } from "./mediaUtils";export function useResolvedExternalMedia(diff --git a/web/src/components/ui/media/useResolvedMedia.clienttest.tsx b/web/src/components/ui/media/useResolvedMedia.clienttest.tsxindex 2b38c448da..db445ea7e9 100644--- a/web/src/components/ui/media/useResolvedMedia.clienttest.tsx+++ b/web/src/components/ui/media/useResolvedMedia.clienttest.tsx@@ -9,7 +9,7 @@ import { type PropsWithChildren } from "react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { useResolvedMedia } from "./useResolvedMedia";-import { useMediaPeek } from "@/src/features/media";+import { useMediaPeek } from "@/src/features/media/hooks/useMediaPeek";import { type RouterOutputs } from "@/src/utils/api";type MediaResponse = RouterOutputs["media"]["getById"];diff --git a/web/src/components/ui/media/useResolvedMedia.ts b/web/src/components/ui/media/useResolvedMedia.tsindex 6750136260..5f3d55ae42 100644--- a/web/src/components/ui/media/useResolvedMedia.ts+++ b/web/src/components/ui/media/useResolvedMedia.ts@@ -1,6 +1,7 @@import { api } from "@/src/utils/api";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";-import { getSignedUrlState, mediaUrlQueryOptions } from "@/src/features/media";+import { getSignedUrlState } from "@/src/features/media/fns/getSignedUrlState";+import { mediaUrlQueryOptions } from "@/src/features/media/constants/mediaUrlQueryOptions";import { type MediaDescriptor } from "./mediaUtils";type LangfuseRefDescriptor = Extract<MediaDescriptor, { kind: "langfuseRef" }>;diff --git a/web/src/components/useShareMenuItems.ts b/web/src/components/useShareMenuItems.tsindex 9c5dc8f872..2f1189dcbd 100644--- a/web/src/components/useShareMenuItems.ts+++ b/web/src/components/useShareMenuItems.ts@@ -5,7 +5,7 @@ import {getShareUrl,usePublishObject,} from "@/src/components/PublishSessionSwitch";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { copyTextToClipboard } from "@/src/utils/clipboard";/**diff --git a/web/src/constants/index.ts b/web/src/constants/index.tsdeleted file mode 100644index d66726a57b..0000000000--- a/web/src/constants/index.ts+++ /dev/null@@ -1 +0,0 @@-export { VERSION } from "./VERSION";diff --git a/web/src/ee/features/access-audit-log/hooks/useAccessAuditLogSetting.ts b/web/src/ee/features/access-audit-log/hooks/useAccessAuditLogSetting.tsindex f92d18cfec..2667e6a845 100644--- a/web/src/ee/features/access-audit-log/hooks/useAccessAuditLogSetting.ts+++ b/web/src/ee/features/access-audit-log/hooks/useAccessAuditLogSetting.ts@@ -1,5 +1,5 @@import { useQueryOrganization } from "@/src/features/organizations/hooks";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { api } from "@/src/utils/api";import { useSession } from "next-auth/react";diff --git a/web/src/ee/features/access-audit-log/hooks/useShowAccessLoggingSetting.ts b/web/src/ee/features/access-audit-log/hooks/useShowAccessLoggingSetting.tsindex dfb2d4a39c..295a02cb72 100644--- a/web/src/ee/features/access-audit-log/hooks/useShowAccessLoggingSetting.ts+++ b/web/src/ee/features/access-audit-log/hooks/useShowAccessLoggingSetting.ts@@ -1,5 +1,5 @@-import { useHasEntitlement } from "@/src/features/entitlements";-import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";import { useSession } from "next-auth/react";/** Whether the org can set access logging: only in "org" mode, since "enforced" and "disabled" leave nothing to choose. */diff --git a/web/src/ee/features/access-audit-log/index.ts b/web/src/ee/features/access-audit-log/index.tsdeleted file mode 100644index ef860d855f..0000000000--- a/web/src/ee/features/access-audit-log/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { AccessLoggingSwitch } from "@/src/ee/features/access-audit-log/components/AccessLoggingSwitch";-export { useShowAccessLoggingSetting } from "@/src/ee/features/access-audit-log/hooks/useShowAccessLoggingSetting";diff --git a/web/src/ee/features/access-audit-log/server/accessAuditLogRouter.ts b/web/src/ee/features/access-audit-log/server/accessAuditLogRouter.tsindex fa3f6cdd76..f2282c1516 100644--- a/web/src/ee/features/access-audit-log/server/accessAuditLogRouter.ts+++ b/web/src/ee/features/access-audit-log/server/accessAuditLogRouter.ts@@ -1,7 +1,7 @@import { env } from "@/src/env.mjs";-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import {createTRPCRouter,protectedOrganizationProcedure,diff --git a/web/src/ee/features/access-audit-log/server/index.ts b/web/src/ee/features/access-audit-log/server/index.tsdeleted file mode 100644index 28c7fe6a90..0000000000--- a/web/src/ee/features/access-audit-log/server/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export {- recordPublicApiAccess,- recordTrpcAccess,-} from "@/src/ee/features/access-audit-log/server/recordAccessEvent";diff --git a/web/src/ee/features/access-audit-log/server/isAccessAuditLogEnabled.ts b/web/src/ee/features/access-audit-log/server/isAccessAuditLogEnabled.tsindex 7cdb99a9c2..61635ff7bb 100644--- a/web/src/ee/features/access-audit-log/server/isAccessAuditLogEnabled.ts+++ b/web/src/ee/features/access-audit-log/server/isAccessAuditLogEnabled.ts@@ -2,7 +2,7 @@ import { type Plan } from "@langfuse/shared";import { env } from "@/src/env.mjs";import { isAuditLogEnabled } from "@/src/features/audit-logs/isAuditLogEnabled";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";/** The org facts the gate reads. The session and API-key scopes carry them, so checking a read needs no query. */export type AccessAuditOrg = {diff --git a/web/src/ee/features/access-audit-log/server/recordAccessEvent.ts b/web/src/ee/features/access-audit-log/server/recordAccessEvent.tsindex 35b7cfeb62..2815e7bb45 100644--- a/web/src/ee/features/access-audit-log/server/recordAccessEvent.ts+++ b/web/src/ee/features/access-audit-log/server/recordAccessEvent.ts@@ -20,12 +20,9 @@ import {isAccessAuditLogEnabled,type AccessAuditOrg,} from "@/src/ee/features/access-audit-log/server/isAccessAuditLogEnabled";-import {- getAuditRequestContext,- toApiKeyActor,- toUserActor,-} from "@/src/features/audit-logs/server";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+import { getAuditRequestContext } from "@/src/features/audit-logs/server/getAuditRequestContext";+import { toApiKeyActor, toUserActor } from "@/src/features/audit-logs/auditLog";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";/** What a route returned: the resource it read, typed refs to every resource in the response, and the validated request input. */export type AccessRead = {diff --git a/web/src/ee/features/admin-api/server/index.ts b/web/src/ee/features/admin-api/server/index.tsdeleted file mode 100644index f4808760bf..0000000000--- a/web/src/ee/features/admin-api/server/index.ts+++ /dev/null@@ -1 +0,0 @@-export { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";diff --git a/web/src/ee/features/admin-api/server/memberships.ts b/web/src/ee/features/admin-api/server/memberships.tsindex d58cc619a4..a6bd5731a1 100644--- a/web/src/ee/features/admin-api/server/memberships.ts+++ b/web/src/ee/features/admin-api/server/memberships.ts@@ -1,14 +1,14 @@import { type NextApiRequest, type NextApiResponse } from "next";import { z } from "zod";-import { getSfdcService } from "@/src/ee/features/sfdc-sync/server";+import { getSfdcService } from "@/src/ee/features/sfdc-sync/server/sfdcService";import {deleteUserBoundApiKeys,deleteUserBoundApiKeysForRole,evictRevokedApiKeys,} from "@/src/features/ai-gateway/server/apiKey/userBoundApiKeys";import { requireGatewayEnabledForRole } from "@/src/features/ai-gateway/server/availability";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { type AuthorizationContext } from "@/src/features/auth/policy/types";import { authorize } from "@/src/features/rbac/authorize";import { ForbiddenError, Role } from "@langfuse/shared";diff --git a/web/src/ee/features/admin-api/server/organizations/apiKeys/apiKeyById.ts b/web/src/ee/features/admin-api/server/organizations/apiKeys/apiKeyById.tsindex d7fe4e7948..9e222a1eed 100644--- a/web/src/ee/features/admin-api/server/organizations/apiKeys/apiKeyById.ts+++ b/web/src/ee/features/admin-api/server/organizations/apiKeys/apiKeyById.ts@@ -1,9 +1,9 @@import { type NextApiRequest, type NextApiResponse } from "next";import { prisma } from "@langfuse/shared/src/db";import { logger, redis } from "@langfuse/shared/src/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { z } from "zod";-import { ApiAuthService } from "@/src/features/public-api/server";+import { ApiAuthService } from "@/src/features/public-api/server/apiAuth";export const validateQueryParams = (query: unknown,diff --git a/web/src/ee/features/admin-api/server/organizations/apiKeys/index.ts b/web/src/ee/features/admin-api/server/organizations/apiKeys/index.tsindex fe6c7c5e34..dc2d403098 100644--- a/web/src/ee/features/admin-api/server/organizations/apiKeys/index.ts+++ b/web/src/ee/features/admin-api/server/organizations/apiKeys/index.ts@@ -1,7 +1,7 @@import { type NextApiRequest, type NextApiResponse } from "next";import { prisma } from "@langfuse/shared/src/db";import { logger } from "@langfuse/shared/src/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { z } from "zod";import { createApiKey } from "@langfuse/shared/src/server/auth/apiKeys";import { OrganizationId, SystemRoleId } from "@langfuse/shared/rbac";diff --git a/web/src/ee/features/admin-api/server/organizations/index.ts b/web/src/ee/features/admin-api/server/organizations/index.tsindex 68b8774b0c..e1b5efc01a 100644--- a/web/src/ee/features/admin-api/server/organizations/index.ts+++ b/web/src/ee/features/admin-api/server/organizations/index.ts@@ -1,7 +1,7 @@import { prisma } from "@langfuse/shared/src/db";import { logger } from "@langfuse/shared/src/server";-import { organizationNameSchema } from "@/src/features/organizations/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { organizationNameSchema } from "@/src/features/organizations/utils/organizationNameSchema";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { type NextApiRequest, type NextApiResponse } from "next";import { z } from "zod";diff --git a/web/src/ee/features/admin-api/server/organizations/organizationById.ts b/web/src/ee/features/admin-api/server/organizations/organizationById.tsindex 76246df771..1a39b3786f 100644--- a/web/src/ee/features/admin-api/server/organizations/organizationById.ts+++ b/web/src/ee/features/admin-api/server/organizations/organizationById.ts@@ -4,8 +4,8 @@ import {invalidateCachedOrgApiKeys,logger,} from "@langfuse/shared/src/server";-import { organizationNameSchema } from "@/src/features/organizations/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { organizationNameSchema } from "@/src/features/organizations/utils/organizationNameSchema";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { z } from "zod";const validateQueryAndExtractId = (query: unknown): string | null => {diff --git a/web/src/ee/features/admin-api/server/projects/createProject.ts b/web/src/ee/features/admin-api/server/projects/createProject.tsindex 60fddf6b5a..5df988294a 100644--- a/web/src/ee/features/admin-api/server/projects/createProject.ts+++ b/web/src/ee/features/admin-api/server/projects/createProject.ts@@ -7,8 +7,8 @@ import {} from "@langfuse/shared/src/server";import { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";import { projectRetentionSchema } from "@/src/features/auth/lib/projectRetentionSchema";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import { emitChbProjectEvent } from "@/src/ee/features/billing/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { emitChbProjectEvent } from "@/src/ee/features/billing/server/chb/chbProjectEvents";export async function handleCreateProject(req: NextApiRequest,diff --git a/web/src/ee/features/admin-api/server/projects/projectById/apiKeys/apiKeyById.ts b/web/src/ee/features/admin-api/server/projects/projectById/apiKeys/apiKeyById.tsindex 61a7314ab0..abd53ab523 100644--- a/web/src/ee/features/admin-api/server/projects/projectById/apiKeys/apiKeyById.ts+++ b/web/src/ee/features/admin-api/server/projects/projectById/apiKeys/apiKeyById.ts@@ -1,8 +1,8 @@import { type NextApiRequest, type NextApiResponse } from "next";import { prisma } from "@langfuse/shared/src/db";import { logger, redis } from "@langfuse/shared/src/server";-import { ApiAuthService } from "@/src/features/public-api/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { ApiAuthService } from "@/src/features/public-api/server/apiAuth";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { z } from "zod";export const validateQueryParams = (diff --git a/web/src/ee/features/admin-api/server/projects/projectById/apiKeys/index.ts b/web/src/ee/features/admin-api/server/projects/projectById/apiKeys/index.tsindex c1f9100c3a..92bd8761be 100644--- a/web/src/ee/features/admin-api/server/projects/projectById/apiKeys/index.ts+++ b/web/src/ee/features/admin-api/server/projects/projectById/apiKeys/index.ts@@ -1,7 +1,7 @@import { type NextApiRequest, type NextApiResponse } from "next";import { prisma } from "@langfuse/shared/src/db";import { logger } from "@langfuse/shared/src/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { z } from "zod";import { createApiKey } from "@langfuse/shared/src/server/auth/apiKeys";import {diff --git a/web/src/ee/features/admin-api/server/projects/projectById/index.ts b/web/src/ee/features/admin-api/server/projects/projectById/index.tsindex e80d06083b..c8e19b526e 100644--- a/web/src/ee/features/admin-api/server/projects/projectById/index.ts+++ b/web/src/ee/features/admin-api/server/projects/projectById/index.ts@@ -1,6 +1,6 @@import { ForbiddenError } from "@langfuse/shared";import { type AuthorizationContext } from "@/src/features/auth/policy/types";-import { ProjectService } from "@/src/features/projects/server";+import { ProjectService } from "@/src/features/projects/server/projectService";import { type NextApiRequest, type NextApiResponse } from "next";import { prisma } from "@langfuse/shared/src/db";import {@@ -10,12 +10,10 @@ import {} from "@langfuse/shared/src/server";import { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";import { projectRetentionSchema } from "@/src/features/auth/lib/projectRetentionSchema";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import {- ApiAuthService,- shadowAuthorize,- writeProjectError,-} from "@/src/features/public-api/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { ApiAuthService } from "@/src/features/public-api/server/apiAuth";+import { shadowAuthorize } from "@/src/features/public-api/server/shadowAuth";+import { writeProjectError } from "@/src/features/public-api/server/writeError";export async function handleUpdateProject(req: NextApiRequest,diff --git a/web/src/ee/features/admin-api/server/projects/projectById/memberships/index.ts b/web/src/ee/features/admin-api/server/projects/projectById/memberships/index.tsindex b1b9bd88f6..84adf07169 100644--- a/web/src/ee/features/admin-api/server/projects/projectById/memberships/index.ts+++ b/web/src/ee/features/admin-api/server/projects/projectById/memberships/index.ts@@ -1,7 +1,7 @@import { type NextApiRequest, type NextApiResponse } from "next";import { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { type AuthorizationContext } from "@/src/features/auth/policy/types";import { authorize } from "@/src/features/rbac/authorize";import { ForbiddenError, Role } from "@langfuse/shared";diff --git a/web/src/ee/features/audit-log-viewer/AuditLogsSettingsPage.tsx b/web/src/ee/features/audit-log-viewer/AuditLogsSettingsPage.tsxindex d9010711a4..f57c13fbb3 100644--- a/web/src/ee/features/audit-log-viewer/AuditLogsSettingsPage.tsx+++ b/web/src/ee/features/audit-log-viewer/AuditLogsSettingsPage.tsx@@ -1,8 +1,8 @@import Header from "@/src/components/layouts/header";import { Alert } from "@/src/components/design-system/Alert/Alert";import { ConnectedAuditLogsTable } from "@/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable";-import { useHasEntitlement } from "@/src/features/entitlements";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export function AuditLogsSettingsPage(props: { projectId: string }) {const hasAccess = useHasProjectAccess({diff --git a/web/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable.tsx b/web/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable.tsxindex eb2f9f9d7b..e327b178e2 100644--- a/web/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable.tsx+++ b/web/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable.tsx@@ -9,8 +9,8 @@ import {import { type AsyncTableData } from "@/src/components/design-system/table/Table";import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";-import { showSuccessToast } from "@/src/features/notifications";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { safeExtract } from "@/src/utils/map-utils";import { AuditLogsTable, type AuditLogRow } from "./AuditLogsTable";diff --git a/web/src/ee/features/audit-log-viewer/OrgAuditLogsSettingsPage.tsx b/web/src/ee/features/audit-log-viewer/OrgAuditLogsSettingsPage.tsxindex 85194219f1..cddc2fcc46 100644--- a/web/src/ee/features/audit-log-viewer/OrgAuditLogsSettingsPage.tsx+++ b/web/src/ee/features/audit-log-viewer/OrgAuditLogsSettingsPage.tsx@@ -1,12 +1,10 @@import Header from "@/src/components/layouts/header";import { Alert } from "@/src/components/design-system/Alert/Alert";-import {- AccessLoggingSwitch,- useShowAccessLoggingSetting,-} from "@/src/ee/features/access-audit-log";+import { AccessLoggingSwitch } from "@/src/ee/features/access-audit-log/components/AccessLoggingSwitch";+import { useShowAccessLoggingSetting } from "@/src/ee/features/access-audit-log/hooks/useShowAccessLoggingSetting";import { ConnectedAuditLogsTable } from "@/src/ee/features/audit-log-viewer/AuditLogsTable/ConnectedAuditLogsTable";-import { useHasEntitlement } from "@/src/features/entitlements";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";export function OrgAuditLogsSettingsPage(props: { orgId: string }) {const hasAccess = useHasOrganizationAccess({diff --git a/web/src/ee/features/audit-log-viewer/index.ts b/web/src/ee/features/audit-log-viewer/index.tsdeleted file mode 100644index d865f9035d..0000000000--- a/web/src/ee/features/audit-log-viewer/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { AuditLogsSettingsPage } from "@/src/ee/features/audit-log-viewer/AuditLogsSettingsPage";-export { OrgAuditLogsSettingsPage } from "@/src/ee/features/audit-log-viewer/OrgAuditLogsSettingsPage";diff --git a/web/src/ee/features/billing/components/BillingActionButtons.tsx b/web/src/ee/features/billing/components/BillingActionButtons.tsxindex c5fc9d71f7..920be4cef7 100644--- a/web/src/ee/features/billing/components/BillingActionButtons.tsx+++ b/web/src/ee/features/billing/components/BillingActionButtons.tsx@@ -3,8 +3,8 @@ import { useMemo } from "react";import { Button } from "@/src/components/ui/button";import Link from "next/link";-import { useSupportDrawer } from "@/src/features/support-chat";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { useV4MigrationPanel } from "@/src/features/v4-migration/V4MigrationPanelProvider";import { StripeCustomerPortalButton } from "./StripeCustomerPortalButton";import { BillingSwitchPlanDialog } from "./BillingSwitchPlanDialog";diff --git a/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx b/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsxindex 1649eb8cf8..97d431f0e9 100644--- a/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx+++ b/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx@@ -13,7 +13,8 @@ import {} from "@/src/components/ui/dialog";import { Input } from "@/src/components/ui/input";import { api } from "@/src/utils/api";-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { nanoid } from "nanoid";diff --git a/web/src/ee/features/billing/components/BillingSettings.tsx b/web/src/ee/features/billing/components/BillingSettings.tsxindex ddbfe85a36..1122f4e7ba 100644--- a/web/src/ee/features/billing/components/BillingSettings.tsx+++ b/web/src/ee/features/billing/components/BillingSettings.tsx@@ -1,9 +1,9 @@/* eslint-disable no-nested-ternary */// Langfuse Cloud only-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import Header from "@/src/components/layouts/header";-import { useHasEntitlement } from "@/src/features/entitlements";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";import { useRouter } from "next/router";import { Alert } from "@/src/components/design-system/Alert/Alert";@@ -17,7 +17,7 @@ import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isClimport { SpendAlertsSection } from "./SpendAlerts/SpendAlertsSection";import { useBillingInformation } from "./useBillingInformation";import { api } from "@/src/utils/api";-import { OrganizationUsageBreakdown } from "@/src/features/organization-usage";+import { OrganizationUsageBreakdown } from "@/src/features/organization-usage/components/OrganizationUsageBreakdown";import { MAX_EVENTS_FREE_PLAN } from "@/src/ee/features/billing/constants";export const BillingSettings = () => {diff --git a/web/src/ee/features/billing/components/BillingSwitchPlanDialog.tsx b/web/src/ee/features/billing/components/BillingSwitchPlanDialog.tsxindex 9fcebcb6e9..01de99b855 100644--- a/web/src/ee/features/billing/components/BillingSwitchPlanDialog.tsx+++ b/web/src/ee/features/billing/components/BillingSwitchPlanDialog.tsx@@ -14,7 +14,7 @@ import {DialogTrigger,DialogBody,} from "@/src/components/ui/dialog";-import { showToast } from "@/src/features/notifications";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";// planLabels used inside StripeSwitchPlanButton@@ -23,7 +23,7 @@ import {isUpgrade,} from "@/src/ee/features/billing/utils/stripeCatalogue";import { ActionButton } from "@/src/components/ActionButton";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useBillingInformation } from "@/src/ee/features/billing/components/useBillingInformation";import { api } from "@/src/utils/api";import { StripeCancellationButton } from "./StripeCancellationButton";diff --git a/web/src/ee/features/billing/components/SpendAlerts/ConnectedDeleteSpendAlertDialogController.tsx b/web/src/ee/features/billing/components/SpendAlerts/ConnectedDeleteSpendAlertDialogController.tsxindex c457d15b61..02e51934eb 100644--- a/web/src/ee/features/billing/components/SpendAlerts/ConnectedDeleteSpendAlertDialogController.tsx+++ b/web/src/ee/features/billing/components/SpendAlerts/ConnectedDeleteSpendAlertDialogController.tsx@@ -1,8 +1,9 @@import { type ComponentProps } from "react";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { api, reportNonTrpcError } from "@/src/utils/api";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";export function ConnectedDeleteSpendAlertDialogController({diff --git a/web/src/ee/features/billing/components/SpendAlerts/ConnectedSpendAlertDialogController.tsx b/web/src/ee/features/billing/components/SpendAlerts/ConnectedSpendAlertDialogController.tsxindex 6d251c1e79..4856387ecd 100644--- a/web/src/ee/features/billing/components/SpendAlerts/ConnectedSpendAlertDialogController.tsx+++ b/web/src/ee/features/billing/components/SpendAlerts/ConnectedSpendAlertDialogController.tsx@@ -14,8 +14,9 @@ import {} from "@/src/components/ui/form";import { Input } from "@/src/components/ui/input";import { api, reportNonTrpcError, type RouterOutputs } from "@/src/utils/api";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { Info } from "@langfuse/icons";diff --git a/web/src/ee/features/billing/components/SpendAlerts/ConnectedSpendAlertsTable.tsx b/web/src/ee/features/billing/components/SpendAlerts/ConnectedSpendAlertsTable.tsxindex b33981cfbf..923e9d0446 100644--- a/web/src/ee/features/billing/components/SpendAlerts/ConnectedSpendAlertsTable.tsx+++ b/web/src/ee/features/billing/components/SpendAlerts/ConnectedSpendAlertsTable.tsx@@ -1,6 +1,6 @@import { useMemo, type ComponentProps } from "react";import { api } from "@/src/utils/api";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { SpendAlertsTable } from "./SpendAlertsTable";import { ConnectedSpendAlertDialogController } from "./ConnectedSpendAlertDialogController";import { ConnectedDeleteSpendAlertDialogController } from "./ConnectedDeleteSpendAlertDialogController";diff --git a/web/src/ee/features/billing/components/StripeCancellationButton.tsx b/web/src/ee/features/billing/components/StripeCancellationButton.tsxindex 6302e530a3..7acadd27b9 100644--- a/web/src/ee/features/billing/components/StripeCancellationButton.tsx+++ b/web/src/ee/features/billing/components/StripeCancellationButton.tsx@@ -13,7 +13,8 @@ import {import { useBillingInformation } from "./useBillingInformation";import { api } from "@/src/utils/api";import { useState } from "react";-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { nanoid } from "nanoid";diff --git a/web/src/ee/features/billing/components/StripeCustomerPortalButton.tsx b/web/src/ee/features/billing/components/StripeCustomerPortalButton.tsxindex 5e701aa1fd..4a66691368 100644--- a/web/src/ee/features/billing/components/StripeCustomerPortalButton.tsx+++ b/web/src/ee/features/billing/components/StripeCustomerPortalButton.tsx@@ -1,7 +1,7 @@import { Button } from "@/src/components/ui/button";import { api } from "@/src/utils/api";import { useEffect, useState } from "react";-import { showToast } from "@/src/features/notifications";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";export const StripeCustomerPortalButton = ({diff --git a/web/src/ee/features/billing/components/StripeKeepPlanButton.tsx b/web/src/ee/features/billing/components/StripeKeepPlanButton.tsxindex 8c71a3c62b..dae264a19e 100644--- a/web/src/ee/features/billing/components/StripeKeepPlanButton.tsx+++ b/web/src/ee/features/billing/components/StripeKeepPlanButton.tsx@@ -12,7 +12,8 @@ import {DialogTrigger,} from "@/src/components/ui/dialog";import { api } from "@/src/utils/api";-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { nanoid } from "nanoid";diff --git a/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx b/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsxindex e1c8d314b2..e79cebbaa7 100644--- a/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx+++ b/web/src/ee/features/billing/components/StripeSwitchPlanButton.tsx@@ -15,7 +15,8 @@ import {import { ActionButton } from "@/src/components/ActionButton";import { planLabels } from "@langfuse/shared";import { api } from "@/src/utils/api";-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { nanoid } from "nanoid";diff --git a/web/src/ee/features/billing/components/useBillingInformation.tsx b/web/src/ee/features/billing/components/useBillingInformation.tsxindex 92ee15859a..24c2a94ec5 100644--- a/web/src/ee/features/billing/components/useBillingInformation.tsx+++ b/web/src/ee/features/billing/components/useBillingInformation.tsx@@ -1,6 +1,6 @@import { useMemo } from "react";-import { useQueryOrganization } from "@/src/features/organizations";+import { useQueryOrganization } from "@/src/features/organizations/hooks";import { formatLocalIsoDate } from "@/src/utils/dates";import { type BillingProvider, type Plan, planLabels } from "@langfuse/shared";import { stripeProducts } from "@/src/ee/features/billing/utils/stripeCatalogue";diff --git a/web/src/ee/features/billing/index.ts b/web/src/ee/features/billing/index.tsdeleted file mode 100644index 8a32993d6e..0000000000--- a/web/src/ee/features/billing/index.ts+++ /dev/null@@ -1,13 +0,0 @@-// The billing feature's public client surface (RFC rule 8). Named-// re-exports only — the upgrade page and cloud-billing hook other-// features already imported by file path.-//-// BillingSettings stays off this door: OrganizationSettingsPage is the-// only consumer, and putting the settings page here would pull billing-// UI into every SupportOrUpgradePage importer. isCloudBillingEnabled-// lives on server/index.ts so server callers do not load this hook.-// stripeCatalogue stays deep so entitlements getPlan does not load the-// billing service graph. chbProjectEvents and resolveBillingService-// live on server/index.ts.-export { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";-export { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";diff --git a/web/src/ee/features/billing/server/chb/chbBillingService.ts b/web/src/ee/features/billing/server/chb/chbBillingService.tsindex 3353208a1b..c2a6596fc5 100644--- a/web/src/ee/features/billing/server/chb/chbBillingService.ts+++ b/web/src/ee/features/billing/server/chb/chbBillingService.ts@@ -2,7 +2,7 @@ import { TRPCError } from "@trpc/server";import { env } from "@/src/env.mjs";import { type OrgAuthedContext } from "@/src/server/api/trpc";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { CloudConfigSchema, parseDbOrg } from "@langfuse/shared";import {getBillingCycleEnd,diff --git a/web/src/ee/features/billing/server/chb/chbWebhookHandler.ts b/web/src/ee/features/billing/server/chb/chbWebhookHandler.tsindex fd69f58b47..8df2f4973b 100644--- a/web/src/ee/features/billing/server/chb/chbWebhookHandler.ts+++ b/web/src/ee/features/billing/server/chb/chbWebhookHandler.ts@@ -4,7 +4,7 @@ import { type NextRequest, NextResponse } from "next/server";import { z } from "zod";import { env } from "@/src/env.mjs";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { invalidateGatewayResolveCacheForOrganization } from "@/src/features/ai-gateway/server/resolve/gatewayResolveCache";import {isoDateTime,diff --git a/web/src/ee/features/billing/server/cloudBillingRouter.ts b/web/src/ee/features/billing/server/cloudBillingRouter.tsindex 0fe4f19dcf..c9935bbd32 100644--- a/web/src/ee/features/billing/server/cloudBillingRouter.ts+++ b/web/src/ee/features/billing/server/cloudBillingRouter.ts@@ -1,14 +1,14 @@import * as z from "zod";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";import {createTRPCRouter,protectedOrganizationProcedure,} from "@/src/server/api/trpc";import { TRPCError } from "@trpc/server";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";-import { auditLog } from "@/src/features/audit-logs/server";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { logger } from "@langfuse/shared/src/server";import { type BillingProvider } from "@langfuse/shared";import { resolveBillingService } from "./resolveBillingService";diff --git a/web/src/ee/features/billing/server/defaultSpendAlerts.ts b/web/src/ee/features/billing/server/defaultSpendAlerts.tsindex dd5d26992e..be6f82822f 100644--- a/web/src/ee/features/billing/server/defaultSpendAlerts.ts+++ b/web/src/ee/features/billing/server/defaultSpendAlerts.ts@@ -2,7 +2,7 @@ import { type Plan } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";import { logger } from "@langfuse/shared/src/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { mapStripeProductIdToPlan } from "@/src/ee/features/billing/utils/stripeCatalogue";/**diff --git a/web/src/ee/features/billing/server/index.ts b/web/src/ee/features/billing/server/index.tsdeleted file mode 100644index c23dd061d7..0000000000--- a/web/src/ee/features/billing/server/index.ts+++ /dev/null@@ -1,11 +0,0 @@-// The billing feature's public server surface (RFC rules 8 and 10).-// cloudBillingRouter and spendAlertRouter stay a direct import from the-// tRPC root. stripeCatalogue stays deep so entitlements getPlan does not-// load the billing service graph.-export {- backfillChbProjectEvents,- emitChbProjectEvent,- sendChbProjectEvent,-} from "@/src/ee/features/billing/server/chb/chbProjectEvents";-export { isCloudBillingEnabled } from "@/src/ee/features/billing/utils/isCloudBillingEnabled";-export { resolveBillingService } from "@/src/ee/features/billing/server/resolveBillingService";diff --git a/web/src/ee/features/billing/server/spendAlertRouter.ts b/web/src/ee/features/billing/server/spendAlertRouter.tsindex 63bed8fe78..4dc1f3328d 100644--- a/web/src/ee/features/billing/server/spendAlertRouter.ts+++ b/web/src/ee/features/billing/server/spendAlertRouter.ts@@ -1,14 +1,14 @@import * as z from "zod";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";import {createTRPCRouter,protectedOrganizationProcedure,} from "@/src/server/api/trpc";import { TRPCError } from "@trpc/server";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";-import { auditLog } from "@/src/features/audit-logs/server";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { auditLog } from "@/src/features/audit-logs/auditLog";export const spendAlertRouter = createTRPCRouter({getSpendAlerts: protectedOrganizationProcedurediff --git a/web/src/ee/features/billing/server/stripe/stripeBillingService.ts b/web/src/ee/features/billing/server/stripe/stripeBillingService.tsindex 1cffa0fdb8..e361676188 100644--- a/web/src/ee/features/billing/server/stripe/stripeBillingService.ts+++ b/web/src/ee/features/billing/server/stripe/stripeBillingService.ts@@ -23,7 +23,7 @@ import {import { stripeClient as defaultStripeClient } from "@/src/ee/features/billing/utils/stripe";import { StripeCatalogue } from "@/src/ee/features/billing/utils/stripeCatalogue";import { createStripeClientReference } from "@/src/ee/features/billing/utils/stripeClientReference";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {makeIdempotencyKey,diff --git a/web/src/ee/features/billing/server/stripe/stripeWebhookHandler.ts b/web/src/ee/features/billing/server/stripe/stripeWebhookHandler.tsindex df6116958f..89d4954a0b 100644--- a/web/src/ee/features/billing/server/stripe/stripeWebhookHandler.ts+++ b/web/src/ee/features/billing/server/stripe/stripeWebhookHandler.ts@@ -21,10 +21,10 @@ import {invalidateCachedOrgApiKeys,startOfDayUTC,} from "@langfuse/shared/src/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { invalidateGatewayResolveCacheForOrganization } from "@/src/features/ai-gateway/server/resolve/gatewayResolveCache";import { type StripeSubscriptionMetadata } from "@/src/ee/features/billing/utils/stripeSubscriptionMetadata";-import { syncOrgPlanChangeToSfdc } from "@/src/ee/features/sfdc-sync/server";+import { syncOrgPlanChangeToSfdc } from "@/src/ee/features/sfdc-sync/server/planChangeSync";import { createDefaultSpendAlertsForStripeProduct } from "@/src/ee/features/billing/server/defaultSpendAlerts";/**diff --git a/web/src/ee/features/billing/utils/isCloudBilling.ts b/web/src/ee/features/billing/utils/isCloudBilling.tsindex 4b339b4947..d8bed273e8 100644--- a/web/src/ee/features/billing/utils/isCloudBilling.ts+++ b/web/src/ee/features/billing/utils/isCloudBilling.ts@@ -1,4 +1,4 @@-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";/*** Client-side hook to check if cloud billing features are available.diff --git a/web/src/ee/features/multi-tenant-sso/createNewSsoConfigHandler.ts b/web/src/ee/features/multi-tenant-sso/createNewSsoConfigHandler.tsindex e071953e5c..1fe3aaeb34 100644--- a/web/src/ee/features/multi-tenant-sso/createNewSsoConfigHandler.ts+++ b/web/src/ee/features/multi-tenant-sso/createNewSsoConfigHandler.ts@@ -7,7 +7,7 @@ import { type NextApiRequest, type NextApiResponse } from "next";import { env } from "@/src/env.mjs";import { logger } from "@langfuse/shared/src/server";import { multiTenantSsoAvailable } from "@/src/ee/features/multi-tenant-sso/multiTenantSsoAvailable";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";export async function createNewSsoConfigHandler(req: NextApiRequest,res: NextApiResponse,diff --git a/web/src/ee/features/multi-tenant-sso/index.ts b/web/src/ee/features/multi-tenant-sso/index.tsdeleted file mode 100644index 2da8a66007..0000000000--- a/web/src/ee/features/multi-tenant-sso/index.ts+++ /dev/null@@ -1,4 +0,0 @@-// The multi-tenant-sso feature's public client surface (RFC rule 8).-// Named re-exports only — the provider schema SSO settings already-// imported by file path. utils stay on server/index.ts.-export { SsoProviderSchema } from "@/src/ee/features/multi-tenant-sso/types";diff --git a/web/src/ee/features/multi-tenant-sso/server/index.ts b/web/src/ee/features/multi-tenant-sso/server/index.tsdeleted file mode 100644index 6277d19007..0000000000--- a/web/src/ee/features/multi-tenant-sso/server/index.ts+++ /dev/null@@ -1,8 +0,0 @@-// The multi-tenant-sso feature's server surface (RFC rule 9, amended):-// domain lookup helpers auth already imported by file path.-export {- findMultiTenantSsoConfig,- getSsoAuthProviderIdForDomain,- isAnySsoConfigured,- loadSsoProviders,-} from "@/src/ee/features/multi-tenant-sso/utils";diff --git a/web/src/ee/features/multi-tenant-sso/server/ssoConfigRouter.ts b/web/src/ee/features/multi-tenant-sso/server/ssoConfigRouter.tsindex 9f5b54713b..de426ac462 100644--- a/web/src/ee/features/multi-tenant-sso/server/ssoConfigRouter.ts+++ b/web/src/ee/features/multi-tenant-sso/server/ssoConfigRouter.ts@@ -1,6 +1,6 @@-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import {createTRPCRouter,protectedOrganizationProcedure,diff --git a/web/src/ee/features/sfdc-sync/scripts/backfillSfdcLeads.ts b/web/src/ee/features/sfdc-sync/scripts/backfillSfdcLeads.tsindex 5bdf659558..c719e9da18 100644--- a/web/src/ee/features/sfdc-sync/scripts/backfillSfdcLeads.ts+++ b/web/src/ee/features/sfdc-sync/scripts/backfillSfdcLeads.ts@@ -125,12 +125,12 @@ import { readFileSync } from "node:fs";import { parseArgs } from "node:util";import { env } from "@/src/env.mjs";+import { deriveLeadSourceFromMemberships } from "@/src/ee/features/sfdc-sync/server/leadSource";import {- deriveLeadSourceFromMemberships,getSfdcService,toSfdcPlan,-} from "@/src/ee/features/sfdc-sync/server";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+} from "@/src/ee/features/sfdc-sync/server/sfdcService";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import { parseDbOrg } from "@langfuse/shared";import { prisma, Role } from "@langfuse/shared/src/db";import { logger } from "@langfuse/shared/src/server";diff --git a/web/src/ee/features/sfdc-sync/server/index.ts b/web/src/ee/features/sfdc-sync/server/index.tsdeleted file mode 100644index aac0e1c5c8..0000000000--- a/web/src/ee/features/sfdc-sync/server/index.ts+++ /dev/null@@ -1,9 +0,0 @@-export {- SfdcService,- getSfdcService,- resetSfdcServiceCacheForTests,- toSfdcPlan,-} from "./sfdcService";-export { syncOrgPlanChangeToSfdc } from "./planChangeSync";-export { deriveLeadSourceFromMemberships } from "./leadSource";-export type { SetUserRoleInput, SfdcLeadSource } from "./sfdcService";diff --git a/web/src/ee/features/sfdc-sync/server/planChangeSync.ts b/web/src/ee/features/sfdc-sync/server/planChangeSync.tsindex 99d105b6ec..f4294bc2cb 100644--- a/web/src/ee/features/sfdc-sync/server/planChangeSync.ts+++ b/web/src/ee/features/sfdc-sync/server/planChangeSync.ts@@ -3,7 +3,7 @@ import { prisma, Role } from "@langfuse/shared/src/db";import { logger, traceException } from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import { deriveLeadSourceFromMemberships } from "./leadSource";import { getSfdcService, toSfdcPlan, type SfdcService } from "./sfdcService";diff --git a/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx b/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsxindex e9aedd7f9e..e28895dfdd 100644--- a/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx+++ b/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx@@ -1,6 +1,7 @@import { useState } from "react";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/ee/features/sso-settings/components/SSOSettings.tsx b/web/src/ee/features/sso-settings/components/SSOSettings.tsxindex 301b4ed0f4..3d689ef021 100644--- a/web/src/ee/features/sso-settings/components/SSOSettings.tsx+++ b/web/src/ee/features/sso-settings/components/SSOSettings.tsx@@ -1,8 +1,8 @@import { Alert } from "@/src/components/design-system/Alert/Alert";import Header from "@/src/components/layouts/header";-import { useHasEntitlement } from "@/src/features/entitlements";-import { useHasOrganizationAccess } from "@/src/features/rbac";-import { VerifiedDomainsSettings } from "@/src/ee/features/verified-domains";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { VerifiedDomainsSettings } from "@/src/ee/features/verified-domains/components/VerifiedDomainsSettings";import { AlertCircle } from "@langfuse/icons";import { ConnectedSsoConfigsTable } from "./SsoConfigsTable/ConnectedSsoConfigsTable";diff --git a/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx b/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsxindex 25b64f07d3..fca42c89a8 100644--- a/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx+++ b/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx@@ -1,5 +1,5 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";@@ -22,7 +22,7 @@ import {FormMessage,} from "@/src/components/ui/form";import { Input } from "@/src/components/ui/input";-import { SsoProviderSchema } from "@/src/ee/features/multi-tenant-sso";+import { SsoProviderSchema } from "@/src/ee/features/multi-tenant-sso/types";import { zodResolver } from "@hookform/resolvers/zod";import { Check, Copy } from "@langfuse/icons";import { useId, useMemo, useState } from "react";diff --git a/web/src/ee/features/sso-settings/components/SsoConfigsTable/ConnectedSsoConfigsTable.tsx b/web/src/ee/features/sso-settings/components/SsoConfigsTable/ConnectedSsoConfigsTable.tsxindex b974941ca8..b1c1cb13fa 100644--- a/web/src/ee/features/sso-settings/components/SsoConfigsTable/ConnectedSsoConfigsTable.tsx+++ b/web/src/ee/features/sso-settings/components/SsoConfigsTable/ConnectedSsoConfigsTable.tsx@@ -1,6 +1,7 @@import { useMemo } from "react";import { api } from "@/src/utils/api";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { Card } from "@/src/components/ui/card";import { DeleteSsoConfigDialogController } from "../DeleteSsoConfigDialogController";diff --git a/web/src/ee/features/sso-settings/index.ts b/web/src/ee/features/sso-settings/index.tsdeleted file mode 100644index d80ecb38ab..0000000000--- a/web/src/ee/features/sso-settings/index.ts+++ /dev/null@@ -1 +0,0 @@-export { SSOSettings } from "@/src/ee/features/sso-settings/components/SSOSettings";diff --git a/web/src/ee/features/ui-customization/index.ts b/web/src/ee/features/ui-customization/index.tsdeleted file mode 100644index 52b6bc3430..0000000000--- a/web/src/ee/features/ui-customization/index.ts+++ /dev/null@@ -1,7 +0,0 @@-// The ui-customization feature's public client surface (RFC rule 8).-// Named re-exports only — exactly what other features already imported.-//-// instanceLinks and productModuleSchema stay deep: layout and the-// uiCustomization router are not features, and routing those files-// through here would pull the React hook into tRPC.-export { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";diff --git a/web/src/ee/features/ui-customization/uiCustomizationRouter.ts b/web/src/ee/features/ui-customization/uiCustomizationRouter.tsindex 2841282810..87ee81d049 100644--- a/web/src/ee/features/ui-customization/uiCustomizationRouter.ts+++ b/web/src/ee/features/ui-customization/uiCustomizationRouter.ts@@ -1,5 +1,5 @@import { env } from "@/src/env.mjs";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import {createTRPCRouter,authenticatedProcedure,diff --git a/web/src/ee/features/ui-customization/useUiCustomization.ts b/web/src/ee/features/ui-customization/useUiCustomization.tsindex 54b320efc0..89d379b363 100644--- a/web/src/ee/features/ui-customization/useUiCustomization.ts+++ b/web/src/ee/features/ui-customization/useUiCustomization.ts@@ -1,4 +1,4 @@-import { useHasEntitlement } from "@/src/features/entitlements";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";import { api } from "@/src/utils/api";export const useUiCustomization = () => {diff --git a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsxindex b4616d5c06..8ea5986478 100644--- a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx+++ b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx@@ -1,5 +1,5 @@/* eslint-disable @repo/no-abstracted-overlay-trigger, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { Alert } from "@/src/components/design-system/Alert/Alert";import { Button } from "@/src/components/ui/button";import { ConnectedVerifiedDomainsSettingsTable } from "./VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable";@@ -22,8 +22,8 @@ import {} from "@/src/components/ui/form";import { Input } from "@/src/components/ui/input";import Header from "@/src/components/layouts/header";-import { useHasEntitlement } from "@/src/features/entitlements";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { api } from "@/src/utils/api";import { zodResolver } from "@hookform/resolvers/zod";import { AlertCircle } from "@langfuse/icons";diff --git a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable.tsx b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable.tsxindex 2c11947e67..5adc1cea0c 100644--- a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable.tsx+++ b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettingsTable/ConnectedVerifiedDomainsSettingsTable.tsx@@ -1,7 +1,8 @@import { useMemo, useState } from "react";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { type AsyncTableData } from "@/src/components/design-system/table/Table";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import {diff --git a/web/src/ee/features/verified-domains/index.ts b/web/src/ee/features/verified-domains/index.tsdeleted file mode 100644index 55805babcb..0000000000--- a/web/src/ee/features/verified-domains/index.ts+++ /dev/null@@ -1 +0,0 @@-export { VerifiedDomainsSettings } from "@/src/ee/features/verified-domains/components/VerifiedDomainsSettings";diff --git a/web/src/ee/features/verified-domains/server/verifiedDomainRouter.ts b/web/src/ee/features/verified-domains/server/verifiedDomainRouter.tsindex 35f65d7b7b..e2fb8df8e5 100644--- a/web/src/ee/features/verified-domains/server/verifiedDomainRouter.ts+++ b/web/src/ee/features/verified-domains/server/verifiedDomainRouter.ts@@ -1,6 +1,6 @@-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import {createTRPCRouter,protectedOrganizationProcedure,diff --git a/web/src/features/account/AccountSettingsPage.tsx b/web/src/features/account/AccountSettingsPage.tsxindex dfab3f5c6a..d6dac04788 100644--- a/web/src/features/account/AccountSettingsPage.tsx+++ b/web/src/features/account/AccountSettingsPage.tsx@@ -29,7 +29,8 @@ import { signOutCleanly } from "@/src/features/auth/lib/signOut";import { SettingsDangerZone } from "@/src/components/SettingsDangerZone";import { StringNoHTML } from "@langfuse/shared";import Link from "next/link";-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/account/index.ts b/web/src/features/account/index.tsdeleted file mode 100644index ac4b307541..0000000000--- a/web/src/features/account/index.ts+++ /dev/null@@ -1 +0,0 @@-export { useAccountSettingsPages } from "@/src/features/account/AccountSettingsPage";diff --git a/web/src/features/ai-features/server/index.ts b/web/src/features/ai-features/server/index.tsdeleted file mode 100644index b6fc50ad56..0000000000--- a/web/src/features/ai-features/server/index.ts+++ /dev/null@@ -1 +0,0 @@-export { resolveLangfuseAiFeatureAvailability } from "@/src/features/ai-features/server/availability";diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard.tsx b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard.tsxindex 37bb981ab7..fabc0b2b55 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard.tsx+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard.tsx@@ -8,7 +8,7 @@ import { GATEWAY_ANALYTICS_WIDGETS } from "@/src/features/ai-gateway/components/import { useGatewayAnalyticsFilters } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayAnalyticsFilters";import { useGatewayAnalyticsLabels } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayAnalyticsLabels";import { useGatewayUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayUnpricedUsage";-import { MultiSelect } from "@/src/features/filters";+import { MultiSelect } from "@/src/features/filters/components/MultiSelect";import {toAbsoluteTimeRange,type TimeRange,diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard.tsx b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard.tsxindex 452819126f..89e81aa279 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard.tsx+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard.tsx@@ -5,7 +5,7 @@ import { GATEWAY_ANALYTICS_WIDGET_SIZE_CLASSES } from "@/src/features/ai-gatewayimport { buildGatewayAnalyticsQuery } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/buildGatewayAnalyticsQuery";import type { GatewayAnalyticsWidget } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget";import { DashboardCard } from "@/src/features/dashboard/components/cards/DashboardCard";-import { WidgetContent } from "@/src/features/widgets";+import { WidgetContent } from "@/src/features/widgets/components/InlineWidget";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";import { Skeleton } from "@/src/components/ui/skeleton";import { cn } from "@/src/utils/tailwind";diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/buildGatewayAnalyticsQuery.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/buildGatewayAnalyticsQuery.tsindex 2dd9327a67..1b848f97ae 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/buildGatewayAnalyticsQuery.ts+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/buildGatewayAnalyticsQuery.ts@@ -5,7 +5,7 @@ import {toQueryChartConfig,type QueryType,} from "@langfuse/shared/query";-import { isTimeSeriesChart } from "@/src/features/widgets";+import { isTimeSeriesChart } from "@/src/features/widgets/chart-library/utils";import type { GatewayAnalyticsWidget } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget";/**diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget.tsindex d40391619c..7b63a6c79c 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget.ts+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget.ts@@ -1,4 +1,4 @@-import type { WidgetExportSource } from "@/src/features/widgets";+import type { WidgetExportSource } from "@/src/features/widgets/utils/import-export-utils";/** Which name lookup turns the first dimension's IDs into readable labels. */export type GatewayAnalyticsLabelSource = "apiKeys" | "users";diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage.tsxindex 438f9f0ad3..0da9abf8a6 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage.tsx@@ -4,7 +4,7 @@ import { Skeleton } from "@/src/components/ui/skeleton";import { GatewayNotSetUpNotice } from "@/src/features/ai-gateway/components/GatewayNotSetUpNotice/GatewayNotSetUpNotice";import { GATEWAY_API_KEYS_DOCS_URL } from "@/src/features/ai-gateway/constants/gatewayDocsUrls";import { useGatewaySettingsAccess } from "@/src/features/ai-gateway/hooks/useGatewaySettingsAccess";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { ConnectedGatewayApiKeysTable } from "@/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable";export function GatewayApiKeysPage({diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.clienttest.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.clienttest.tsxindex c9937e493e..4310f4ad54 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.clienttest.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.clienttest.tsx@@ -18,7 +18,7 @@ vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));-vi.mock("@/src/features/rbac", () => ({+vi.mock("@/src/features/rbac/utils/checkOrganizationAccess", () => ({useHasOrganizationAccess: () => false,}));diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.tsxindex 73c49e0d4e..738e70a0a7 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.tsx@@ -18,14 +18,12 @@ import {import { InfoTooltip } from "@/src/components/ui/InfoTooltip/InfoTooltip";import { Input } from "@/src/components/ui/input";import { Label } from "@/src/components/ui/label";-import {- ApiKeyExpirationInput,- type ApiKeyExpirationPreset,- resolveApiKeyExpiration,-} from "@/src/features/apiKey";+import { ApiKeyExpirationInput } from "@/src/features/apiKey/components/ApiKeyExpirationInput/ApiKeyExpirationInput";+import type { ApiKeyExpirationPreset } from "@/src/features/apiKey/constants/apiKeyExpirationOptions";+import { resolveApiKeyExpiration } from "@/src/features/apiKey/fns/resolveApiKeyExpiration";import { GeneratedKeyContent } from "@/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/GeneratedKeyContent";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import {api,reportNonTrpcError,diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable.tsxindex 931ee48d98..1c9d6556b8 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable.tsx@@ -9,7 +9,7 @@ import { TeamInviteDialogController } from "@/src/features/ai-gateway/componentsimport { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { usePaginationState } from "@/src/hooks/usePaginationState";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { useGatewayApiKeysTableData } from "@/src/features/ai-gateway/hooks/useGatewayApiKeysTableData";import { api } from "@/src/utils/api";import { GatewayApiKeysTable } from "./GatewayApiKeysTable";diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/GatewayApiKeysTable.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/GatewayApiKeysTable.tsxindex 21eb5d3dae..888e8853ba 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/GatewayApiKeysTable.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/GatewayApiKeysTable.tsx@@ -15,7 +15,7 @@ import type {TableProps,} from "@/src/components/design-system/table/Table";import type { LangfuseColumnDef } from "@/src/components/table/types";-import { isApiKeyExpired } from "@/src/features/apiKey";+import { isApiKeyExpired } from "@/src/features/apiKey/helpers/isApiKeyExpired";import { GATEWAY_API_KEY_LAST_USED_WINDOW_DAYS } from "@/src/features/ai-gateway/constants/gatewayApiKeyLastUsed";import { GatewayApiKeysEmptyState } from "@/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/components/GatewayApiKeysEmptyState/GatewayApiKeysEmptyState";diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/TeamInviteDialogController/fns/showInviteOutcome.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/TeamInviteDialogController/fns/showInviteOutcome.tsindex 6d087d308d..72854f0a3a 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/TeamInviteDialogController/fns/showInviteOutcome.ts+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/TeamInviteDialogController/fns/showInviteOutcome.ts@@ -1,4 +1,5 @@-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import type { RouterOutputs } from "@/src/utils/api";/** The server silently skips the caller's own address, and members it cannot email. */diff --git a/web/src/features/ai-gateway/components/GatewayConnectionModelsPage/components/GatewayConnectionModelsTable/GatewayConnectionModelsTable.tsx b/web/src/features/ai-gateway/components/GatewayConnectionModelsPage/components/GatewayConnectionModelsTable/GatewayConnectionModelsTable.tsxindex 25153f93ec..527b7e7a6c 100644--- a/web/src/features/ai-gateway/components/GatewayConnectionModelsPage/components/GatewayConnectionModelsTable/GatewayConnectionModelsTable.tsx+++ b/web/src/features/ai-gateway/components/GatewayConnectionModelsPage/components/GatewayConnectionModelsTable/GatewayConnectionModelsTable.tsx@@ -6,7 +6,7 @@ import { DataTable } from "@/src/components/table/data-table";import type { CustomHeights } from "@/src/components/table/data-table-row-height-switch";import { createTableSelectionStore } from "@/src/components/table/table-selection-store";import type { LangfuseColumnDef } from "@/src/components/table/types";-import { TableSelectionManager } from "@/src/features/table";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";import { isGatewayModelAllowed } from "@/src/features/ai-gateway/fns/isGatewayModelAllowed";import { toGatewayAllowedModelsSet } from "@/src/features/ai-gateway/fns/toGatewayAllowedModelsSet";import {diff --git a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/IngestionDialogController.tsx b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/IngestionDialogController.tsxindex bfcafa272b..f1cff89c9b 100644--- a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/IngestionDialogController.tsx+++ b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/IngestionDialogController.tsx@@ -8,7 +8,7 @@ import type {GatewayIngestionSettings,GatewayProject,} from "@/src/features/ai-gateway/components/GatewaySetupPage/types/gatewaySetup";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";export type IngestionDialogControllerProps = {organizationId: string;diff --git a/web/src/features/ai-gateway/hooks/useGatewaySettingsAccess.ts b/web/src/features/ai-gateway/hooks/useGatewaySettingsAccess.tsindex 81ebee86b7..faf95b0da6 100644--- a/web/src/features/ai-gateway/hooks/useGatewaySettingsAccess.ts+++ b/web/src/features/ai-gateway/hooks/useGatewaySettingsAccess.ts@@ -2,8 +2,8 @@ import { useSession } from "next-auth/react";import { env } from "@/src/env.mjs";import { canReadGatewayModels } from "@/src/features/ai-gateway/fns/canReadGatewayModels";-import { useIsFeatureEnabled } from "@/src/features/feature-flags";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { api } from "@/src/utils/api";/**diff --git a/web/src/features/ai-gateway/index.ts b/web/src/features/ai-gateway/index.tsdeleted file mode 100644index 993fb95c6e..0000000000--- a/web/src/features/ai-gateway/index.ts+++ /dev/null@@ -1,5 +0,0 @@-export { GatewayAnalyticsPage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/GatewayAnalyticsPage";-export { GatewayApiKeysPage } from "@/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage";-export { GatewayModelsPage } from "@/src/features/ai-gateway/components/GatewayModelsPage/GatewayModelsPage";-export { GatewayNotDeployedNotice } from "@/src/features/ai-gateway/components/GatewayNotDeployedNotice/GatewayNotDeployedNotice";-export { GatewaySetupPage } from "@/src/features/ai-gateway/components/GatewaySetupPage/GatewaySetupPage";diff --git a/web/src/features/ai-gateway/server/apiKey/gatewayApiKeyService.ts b/web/src/features/ai-gateway/server/apiKey/gatewayApiKeyService.tsindex 7e465a9390..57d02c88ea 100644--- a/web/src/features/ai-gateway/server/apiKey/gatewayApiKeyService.ts+++ b/web/src/features/ai-gateway/server/apiKey/gatewayApiKeyService.ts@@ -18,8 +18,8 @@ import {import type { Cluster, Redis } from "ioredis";import { env } from "@/src/env.mjs";-import { auditLog } from "@/src/features/audit-logs/server";-import type { GatewayMetadata } from "@/src/features/ai-gateway/server/provider";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import type { GatewayMetadata } from "@/src/features/ai-gateway/server/provider/registry";import type { OrgAuthedContext } from "@/src/server/api/trpc";import { invalidateGatewayResolveCacheForApiKey } from "@/src/features/ai-gateway/server/resolve/gatewayResolveCache";import { hasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";diff --git a/web/src/features/ai-gateway/server/apiKey/userBoundApiKeys.ts b/web/src/features/ai-gateway/server/apiKey/userBoundApiKeys.tsindex acb6d7955b..d5cc9b8e24 100644--- a/web/src/features/ai-gateway/server/apiKey/userBoundApiKeys.ts+++ b/web/src/features/ai-gateway/server/apiKey/userBoundApiKeys.ts@@ -1,6 +1,10 @@import type { ApiKey, Prisma, Role } from "@langfuse/shared/src/db";import { invalidateCachedApiKeys, logger } from "@langfuse/shared/src/server";-import { auditLog, type AuditLogActor } from "@/src/features/audit-logs/server";+import {+ auditLog,+ type AuditLogActor,+} from "@/src/features/audit-logs/auditLog";+import { invalidateGatewayResolveCacheForApiKey } from "@/src/features/ai-gateway/server/resolve/gatewayResolveCache";import { hasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";diff --git a/web/src/features/ai-gateway/server/auth/gatewayApiKeyAuthenticator.ts b/web/src/features/ai-gateway/server/auth/gatewayApiKeyAuthenticator.tsindex f6497ff3f1..a009627d3f 100644--- a/web/src/features/ai-gateway/server/auth/gatewayApiKeyAuthenticator.ts+++ b/web/src/features/ai-gateway/server/auth/gatewayApiKeyAuthenticator.ts@@ -5,7 +5,7 @@ import { ApiKeyId, OrganizationId } from "@langfuse/shared/rbac";import { authorize } from "@/src/features/rbac/authorize";import { getRolesForPrincipal } from "@/src/features/rbac/getRolesForPrincipal";import { hasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import { isGatewayEnabledForOrganization } from "@/src/features/ai-gateway/server/availability";import { GatewayControlPlaneError } from "@/src/features/ai-gateway/server/gatewayControlPlaneError";import {diff --git a/web/src/features/ai-gateway/server/auth/gatewayRequestSignatureVerifier.ts b/web/src/features/ai-gateway/server/auth/gatewayRequestSignatureVerifier.tsindex 6d9dd84bf5..5102742e46 100644--- a/web/src/features/ai-gateway/server/auth/gatewayRequestSignatureVerifier.ts+++ b/web/src/features/ai-gateway/server/auth/gatewayRequestSignatureVerifier.ts@@ -8,7 +8,11 @@ import { env } from "@/src/env.mjs";import { verifyHmacSha256 } from "@/src/server/utils/hmac";import { createShaHash } from "@langfuse/shared/src/server/auth/apiKeys";-import { GatewayApiFormatSchema, type GatewayApiFormat } from "../provider";+import {+ GatewayApiFormatSchema,+ type GatewayApiFormat,+} from "@/src/features/ai-gateway/server/provider/registry";+import { GatewayControlPlaneError } from "@/src/features/ai-gateway/server/gatewayControlPlaneError";import { GatewayModelRoutingService } from "@/src/features/ai-gateway/server/routing/gatewayModelRoutingService";diff --git a/web/src/features/ai-gateway/server/auth/index.ts b/web/src/features/ai-gateway/server/auth/index.tsdeleted file mode 100644index 638c306046..0000000000--- a/web/src/features/ai-gateway/server/auth/index.ts+++ /dev/null@@ -1,5 +0,0 @@-export {- withGatewayModelsSignatureVerification,- withGatewayResolveSignatureVerification,-} from "./gatewayRequestSignatureVerifier";-export { verifyGatewayIngestionAuthorization } from "./ingestionTokenVerifier";diff --git a/web/src/features/ai-gateway/server/auth/ingestionTokenVerifier.ts b/web/src/features/ai-gateway/server/auth/ingestionTokenVerifier.tsindex b30690cd91..504615e3b3 100644--- a/web/src/features/ai-gateway/server/auth/ingestionTokenVerifier.ts+++ b/web/src/features/ai-gateway/server/auth/ingestionTokenVerifier.ts@@ -1,5 +1,5 @@import { env } from "@/src/env.mjs";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import { CloudConfigSchema, UnauthorizedError } from "@langfuse/shared";import { prisma, type PrismaClient } from "@langfuse/shared/src/db";import {diff --git a/web/src/features/ai-gateway/server/config/gatewayConfigService.ts b/web/src/features/ai-gateway/server/config/gatewayConfigService.tsindex 137f85846d..17ad750496 100644--- a/web/src/features/ai-gateway/server/config/gatewayConfigService.ts+++ b/web/src/features/ai-gateway/server/config/gatewayConfigService.ts@@ -4,7 +4,10 @@ import type {Prisma,PrismaClient,} from "@langfuse/shared/src/db";-import { auditLog, type AuditLogActor } from "@/src/features/audit-logs/server";+import {+ auditLog,+ type AuditLogActor,+} from "@/src/features/audit-logs/auditLog";import type { OrgAuthedContext } from "@/src/server/api/trpc";import { invalidateGatewayResolveCacheForOrganization } from "@/src/features/ai-gateway/server/resolve/gatewayResolveCache";import { isGatewayIngestionConfigured } from "@/src/features/ai-gateway/fns/isGatewayIngestionConfigured";diff --git a/web/src/features/ai-gateway/server/index.ts b/web/src/features/ai-gateway/server/index.tsdeleted file mode 100644index cee897d29f..0000000000--- a/web/src/features/ai-gateway/server/index.ts+++ /dev/null@@ -1,13 +0,0 @@-export {- verifyGatewayIngestionAuthorization,- withGatewayModelsSignatureVerification,- withGatewayResolveSignatureVerification,-} from "./auth";-export { GatewayConfigService } from "./config/gatewayConfigService";-export { gatewayModelsApiHandler } from "./provider/models/gatewayModelsApiHandler";-export { gatewayResolveApiHandler } from "./resolve/gatewayResolveApiHandler";-export {- invalidateGatewayResolveCacheForApiKey,- invalidateGatewayResolveCacheForOrganization,-} from "./resolve/gatewayResolveCache";-export { aiGatewayRouter } from "./router";diff --git a/web/src/features/ai-gateway/server/provider/connection/gatewayProviderService.ts b/web/src/features/ai-gateway/server/provider/connection/gatewayProviderService.tsindex 222436fe21..07d5989893 100644--- a/web/src/features/ai-gateway/server/provider/connection/gatewayProviderService.ts+++ b/web/src/features/ai-gateway/server/provider/connection/gatewayProviderService.ts@@ -13,7 +13,7 @@ import { encrypt } from "@langfuse/shared/encryption";import { LLMAdapter, testModelCall } from "@langfuse/shared/src/server";import { getDisplaySecretKey } from "@langfuse/shared/src/server/auth/apiKeys";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { GATEWAY_CONNECTION_NAME_ERRORS } from "@/src/features/ai-gateway/constants/gatewayConnection";import type { OrgAuthedContext } from "@/src/server/api/trpc";import {diff --git a/web/src/features/ai-gateway/server/provider/index.ts b/web/src/features/ai-gateway/server/provider/index.tsdeleted file mode 100644index 2c012a00cc..0000000000--- a/web/src/features/ai-gateway/server/provider/index.ts+++ /dev/null@@ -1,14 +0,0 @@-export { GatewayProviderService } from "./connection/gatewayProviderService";-export { GatewayModelCatalogService } from "./models/gatewayModelCatalogService";-export {- GatewayApiFormatSchema,- GatewayMetadataSchema,- GatewayModelsResponseSchema,- GatewayResolveResponseSchema,- getGatewayProviderDefinition,- providerSupportsApiFormat,- type GatewayApiFormat,- type GatewayMetadata,- type GatewayProviderId,- type GatewayResolveResponse,-} from "./registry";diff --git a/web/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService.ts b/web/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService.tsindex 059b870a78..5c0b859148 100644--- a/web/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService.ts+++ b/web/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService.ts@@ -7,7 +7,7 @@ import { decrypt } from "@langfuse/shared/encryption";import { logger, redis as defaultRedis } from "@langfuse/shared/src/server";import type { Cluster, Redis } from "ioredis";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { invalidateGatewayResolveCacheForOrganization } from "@/src/features/ai-gateway/server/resolve/gatewayResolveCache";import type { OrgAuthedContext } from "@/src/server/api/trpc";import {diff --git a/web/src/features/ai-gateway/server/provider/models/gatewayModelsApiHandler.ts b/web/src/features/ai-gateway/server/provider/models/gatewayModelsApiHandler.tsindex 5cb9d1553d..cc74271f89 100644--- a/web/src/features/ai-gateway/server/provider/models/gatewayModelsApiHandler.ts+++ b/web/src/features/ai-gateway/server/provider/models/gatewayModelsApiHandler.ts@@ -7,7 +7,8 @@ import { GatewayControlPlaneError } from "@/src/features/ai-gateway/server/gatewimport {type GatewayApiFormat,GatewayModelsResponseSchema,-} from "@/src/features/ai-gateway/server/provider";+} from "@/src/features/ai-gateway/server/provider/registry";+import { GatewayModelsService } from "./gatewayModelsService";export async function gatewayModelsApiHandler({diff --git a/web/src/features/ai-gateway/server/provider/registry.servertest.ts b/web/src/features/ai-gateway/server/provider/registry.servertest.tsindex 7c11582a4e..a8e3aa92de 100644--- a/web/src/features/ai-gateway/server/provider/registry.servertest.ts+++ b/web/src/features/ai-gateway/server/provider/registry.servertest.ts@@ -1,11 +1,11 @@import { describe, expect, it, vi } from "vitest";+import { GatewayModelCatalogService } from "@/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService";+import { GatewayProviderService } from "@/src/features/ai-gateway/server/provider/connection/gatewayProviderService";import {- GatewayModelCatalogService,- GatewayProviderService,getGatewayProviderDefinition,providerSupportsApiFormat,-} from ".";+} from "@/src/features/ai-gateway/server/provider/registry";import type { PrismaClient } from "@langfuse/shared/src/db";import { encrypt } from "@langfuse/shared/encryption";import type { Redis } from "ioredis";diff --git a/web/src/features/ai-gateway/server/resolve/gatewayResolveApiHandler.ts b/web/src/features/ai-gateway/server/resolve/gatewayResolveApiHandler.tsindex dcabdc3081..d15660cd11 100644--- a/web/src/features/ai-gateway/server/resolve/gatewayResolveApiHandler.ts+++ b/web/src/features/ai-gateway/server/resolve/gatewayResolveApiHandler.ts@@ -6,7 +6,7 @@ import { GatewayApiKeyAuthenticator } from "@/src/features/ai-gateway/server/autimport {type GatewayApiFormat,GatewayResolveResponseSchema,-} from "@/src/features/ai-gateway/server/provider";+} from "@/src/features/ai-gateway/server/provider/registry";import {enforceGatewayRateLimits,GatewayRateLimitError,diff --git a/web/src/features/ai-gateway/server/resolve/resolveService.servertest.ts b/web/src/features/ai-gateway/server/resolve/resolveService.servertest.tsindex bce5000049..b7e9ca80c5 100644--- a/web/src/features/ai-gateway/server/resolve/resolveService.servertest.ts+++ b/web/src/features/ai-gateway/server/resolve/resolveService.servertest.ts@@ -2,7 +2,7 @@ import type { PrismaClient } from "@langfuse/shared/src/db";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { GatewayApiKeyAuthenticator } from "@/src/features/ai-gateway/server/auth/gatewayApiKeyAuthenticator";-import type { GatewayApiFormat } from "@/src/features/ai-gateway/server/provider";+import type { GatewayApiFormat } from "@/src/features/ai-gateway/server/provider/registry";import { GatewayResolveService } from "./resolveService";const mockEnv = vi.hoisted(() => ({diff --git a/web/src/features/ai-gateway/server/resolve/resolveService.ts b/web/src/features/ai-gateway/server/resolve/resolveService.tsindex 2a79030a90..fd1531bc83 100644--- a/web/src/features/ai-gateway/server/resolve/resolveService.ts+++ b/web/src/features/ai-gateway/server/resolve/resolveService.ts@@ -18,7 +18,7 @@ import {type GatewayProviderId,type GatewayResolveResponse,getGatewayProviderDefinition,-} from "@/src/features/ai-gateway/server/provider";+} from "@/src/features/ai-gateway/server/provider/registry";export { GatewayControlPlaneError as GatewayResolveError } from "@/src/features/ai-gateway/server/gatewayControlPlaneError";diff --git a/web/src/features/ai-gateway/server/router.ts b/web/src/features/ai-gateway/server/router.tsindex c4ae663be3..a13b8aac0b 100644--- a/web/src/features/ai-gateway/server/router.ts+++ b/web/src/features/ai-gateway/server/router.ts@@ -4,7 +4,7 @@ import type { Session } from "next-auth";import {hasOrganizationAccess,throwIfNoOrganizationAccess,-} from "@/src/features/rbac";+} from "@/src/features/rbac/utils/checkOrganizationAccess";import {createTRPCRouter,protectedOrganizationProcedure,@@ -36,11 +36,9 @@ import {import { GatewayAnalyticsLabelsRepository } from "./analytics/gatewayAnalyticsLabelsRepository";import { GatewayConfigService } from "./config/gatewayConfigService";import { GatewayTeamService } from "./team/gatewayTeamService";-import {- GatewayMetadataSchema,- GatewayModelCatalogService,- GatewayProviderService,-} from "./provider";+import { GatewayMetadataSchema } from "@/src/features/ai-gateway/server/provider/registry";+import { GatewayModelCatalogService } from "@/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService";+import { GatewayProviderService } from "@/src/features/ai-gateway/server/provider/connection/gatewayProviderService";const organizationInput = z.object({ orgId: z.string() });/** Naming rules live in `parseGatewayConnectionName` so the dialog can show them on the field. */diff --git a/web/src/features/ai-gateway/server/team/gatewayTeamService.ts b/web/src/features/ai-gateway/server/team/gatewayTeamService.tsindex 8c478194af..f6545d5919 100644--- a/web/src/features/ai-gateway/server/team/gatewayTeamService.ts+++ b/web/src/features/ai-gateway/server/team/gatewayTeamService.ts@@ -14,13 +14,11 @@ import {import { env } from "@/src/env.mjs";import {getSfdcService,- type SetUserRoleInput,type SfdcService,-} from "@/src/ee/features/sfdc-sync/server";-import {- inviteOrganizationMember,- OrganizationMembersService,-} from "@/src/features/rbac/server";+ type SetUserRoleInput,+} from "@/src/ee/features/sfdc-sync/server/sfdcService";+import { inviteOrganizationMember } from "@/src/features/rbac/server/inviteOrganizationMember";+import { OrganizationMembersService } from "@/src/features/rbac/server/organizationMembersService";import type { OrgAuthedContext } from "@/src/server/api/trpc";const MEMBER_SUGGESTION_LIMIT = 4;diff --git a/web/src/features/analytics-integrations/index.ts b/web/src/features/analytics-integrations/index.tsdeleted file mode 100644index 6d0358900c..0000000000--- a/web/src/features/analytics-integrations/index.ts+++ /dev/null@@ -1,16 +0,0 @@-// The analytics-integrations feature's public client surface (RFC rule 8).-// Named re-exports only — the export-source UI adapters and settings-// skeleton other features already imported by file path.-//-// server/exportSource, displayCredential, and isPrismaRecordNotFoundError-// live on server/index.ts. Routers stay off this door.-export { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations/components/IntegrationSettingsSkeleton";-export {- buildExportSourceContext,- getExportSourceFieldState,- getExportSourceFormValue,- getExportSourceOptions,- getExportSourceUnavailableMessage,- isExportSourceSelectable,- shouldHideExportSourceSelector,-} from "@/src/features/analytics-integrations/exportSource";diff --git a/web/src/features/analytics-integrations/server/index.ts b/web/src/features/analytics-integrations/server/index.tsdeleted file mode 100644index c09d7989f8..0000000000--- a/web/src/features/analytics-integrations/server/index.ts+++ /dev/null@@ -1,8 +0,0 @@-// The analytics-integrations feature's public server surface (RFC rules 8-// and 10). Integration routers stay a direct import from the tRPC root.-export { getDisplayCredential } from "@/src/features/analytics-integrations/server/displayCredential";-export {- assertPersistedExportSourceAllowed,- resolveExportSource,-} from "@/src/features/analytics-integrations/server/exportSource";-export { isPrismaRecordNotFoundError } from "@langfuse/shared/src/server";diff --git a/web/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController.tsx b/web/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController.tsxindex 1258d55ada..d1f364cee1 100644--- a/web/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController.tsx+++ b/web/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController.tsx@@ -3,8 +3,8 @@ import { type ReactNode, useState } from "react";import { ActionId, BatchExportTableName } from "@langfuse/shared";import { api } from "@/src/utils/api";import { Dialog, DialogContent } from "@/src/components/ui/dialog";-import { useHasProjectAccess } from "@/src/features/rbac";-import { useEntitlementLimit } from "@/src/features/entitlements";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";import { AddTracesToAnnotationQueueSelectDialogContent } from "@/src/features/annotation-queues/components/AddTracesToAnnotationQueueSelectDialogContent";import { AnnotationQueueFormDialogController } from "@/src/features/annotation-queues/components/AnnotationQueueFormDialogController";diff --git a/web/src/features/annotation-queues/components/AnnotationQueueDetails.tsx b/web/src/features/annotation-queues/components/AnnotationQueueDetails.tsxindex 098dff1bea..326707516d 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueDetails.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueDetails.tsx@@ -1,6 +1,6 @@import { type ReactNode, useState } from "react";import { SearchInput } from "@/src/components/design-system/SearchInput/SearchInput";-import { getScoreDataTypeIcon } from "@/src/features/scores";+import { getScoreDataTypeIcon } from "@/src/features/scores/lib/scoreColumns";import { Badge } from "@/src/components/design-system/Badge/Badge";import { type ScoreConfigDomain } from "@langfuse/shared";diff --git a/web/src/features/annotation-queues/components/AnnotationQueueFormDialogController.clienttest.tsx b/web/src/features/annotation-queues/components/AnnotationQueueFormDialogController.clienttest.tsxindex ccb43e4bf8..c19510fac0 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueFormDialogController.clienttest.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueFormDialogController.clienttest.tsx@@ -15,9 +15,13 @@ const { create, update, assign, notify, draft } = vi.hoisted(() => ({},}));-vi.mock("@/src/features/rbac", () => ({ useHasProjectAccess: () => true }));-vi.mock("@/src/features/notifications", () => ({ showErrorToast: notify }));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({+ useHasProjectAccess: () => true,+}));+vi.mock("@/src/features/notifications/showErrorToast", () => ({+ showErrorToast: notify,+}));+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));vi.mock("./AnnotationQueueFormDialogContent", () => ({diff --git a/web/src/features/annotation-queues/components/AnnotationQueueFormDialogController.tsx b/web/src/features/annotation-queues/components/AnnotationQueueFormDialogController.tsxindex b1f64ba460..7c1d415b95 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueFormDialogController.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueFormDialogController.tsx@@ -4,8 +4,8 @@ import { type CreateQueueWithAssignments } from "@langfuse/shared";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { Skeleton } from "@/src/components/ui/skeleton";import { Dialog } from "@/src/components/design-system/Dialog/Dialog";-import { showErrorToast } from "@/src/features/notifications";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { AnnotationQueueFormDialogContent } from "@/src/features/annotation-queues/components/AnnotationQueueFormDialogContent";import { QueueScoreConfigFields } from "./QueueScoreConfigFields";import { useWatchedPromiseCallback } from "@/src/hooks/useWatchedPromiseCallback";diff --git a/web/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController.tsx b/web/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController.tsxindex edfe0f4b14..3d49bbe58d 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController.tsx@@ -6,12 +6,12 @@ import {AnnotationQueueItemMenuContent,type AnnotationQueueItemMenuQueue,} from "@/src/features/annotation-queues/components/AnnotationQueueItemMenuContent";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api, reportNonTrpcError } from "@/src/utils/api";import { type AnnotationQueueObjectType } from "@langfuse/shared";import { type ReactNode, useCallback, useState } from "react";import { useSession } from "next-auth/react";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type AnalyticsData } from "@/src/features/scores/types";type AnnotationQueueItemDropdownMenuControllerProps = {diff --git a/web/src/features/annotation-queues/components/AnnotationQueueItemPage.tsx b/web/src/features/annotation-queues/components/AnnotationQueueItemPage.tsxindex 179c2ca148..db18ab9df6 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueItemPage.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueItemPage.tsx@@ -1,7 +1,7 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */import { Card } from "@/src/components/ui/card";import { Skeleton } from "@/src/components/ui/skeleton";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import {AnnotationQueueStatus,@@ -34,7 +34,7 @@ import {isInteractiveTarget,isOpenDialogPresent,isTypingTarget,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/keyboardShortcuts";import { useAnnotationQueueData } from "./shared/hooks/useAnnotationQueueData";import { useAnnotationObjectData } from "./shared/hooks/useAnnotationObjectData";import { TraceAnnotationProcessor } from "./processors/TraceAnnotationProcessor";diff --git a/web/src/features/annotation-queues/components/AnnotationQueueItemsTable.tsx b/web/src/features/annotation-queues/components/AnnotationQueueItemsTable.tsxindex 20c62f83ae..50c6b3292f 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueItemsTable.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueItemsTable.tsx@@ -5,10 +5,8 @@ import { api } from "@/src/utils/api";import { safeExtract } from "@/src/utils/map-utils";import { useQueryParams, withDefault, NumberParam } from "use-query-params";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { type AnnotationQueueStatus } from "@langfuse/shared";import {customRowHeightMenu,@@ -30,9 +28,9 @@ import {DialogTitle,} from "@/src/components/ui/dialog";import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";-import { useHasProjectAccess } from "@/src/features/rbac";-import { useReadPath } from "@/src/features/events";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";import { createIdTableColumn } from "@/src/components/design-system/table/columns/createIdTableColumn";diff --git a/web/src/features/annotation-queues/components/AnnotationQueueScoreConfigEditor.tsx b/web/src/features/annotation-queues/components/AnnotationQueueScoreConfigEditor.tsxindex 78ddc40516..7fc9b28046 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueScoreConfigEditor.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueScoreConfigEditor.tsx@@ -2,7 +2,7 @@import { Info, Pencil, Plus, X } from "@langfuse/icons";import { arrayMove } from "@dnd-kit/sortable";import { type ScoreConfigDomain } from "@langfuse/shared";-import { formatScoreRange } from "@/src/features/scores";+import { formatScoreRange } from "@/src/features/scores/lib/helpers";import { Badge } from "@/src/components/design-system/Badge/Badge";import { IconButton } from "@/src/components/design-system/IconButton/IconButton";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";diff --git a/web/src/features/annotation-queues/components/AnnotationQueueSetupController.clienttest.tsx b/web/src/features/annotation-queues/components/AnnotationQueueSetupController.clienttest.tsxindex a8138964ac..ef70f6cc3f 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueSetupController.clienttest.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueSetupController.clienttest.tsx@@ -24,11 +24,13 @@ const mocks = vi.hoisted(() => ({},}));-vi.mock("@/src/features/rbac", () => ({ useHasProjectAccess: () => true }));+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({+ useHasProjectAccess: () => true,+}));vi.mock("@/src/hooks/use-mobile", () => ({useIsMobile: () => mocks.isMobile,}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => mocks.capture,}));vi.mock("./QueueScoreConfigFields", () => ({diff --git a/web/src/features/annotation-queues/components/AnnotationQueueSetupController.tsx b/web/src/features/annotation-queues/components/AnnotationQueueSetupController.tsxindex 3a02c7f12b..b4f0ebf260 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueSetupController.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueSetupController.tsx@@ -1,8 +1,8 @@import { type ReactNode } from "react";import { Button } from "@/src/components/design-system/Button/Button";import { Skeleton } from "@/src/components/ui/skeleton";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api, type RouterInputs } from "@/src/utils/api";import { AnnotationQueueDetails } from "./AnnotationQueueDetails";import {diff --git a/web/src/features/annotation-queues/components/AnnotationQueueSubmenuItemController.tsx b/web/src/features/annotation-queues/components/AnnotationQueueSubmenuItemController.tsxindex d00ffac17d..33eafafa31 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueSubmenuItemController.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueSubmenuItemController.tsx@@ -6,8 +6,8 @@ import { type ReactNode, useCallback, useMemo } from "react";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { type DropdownMenuItemDefinition } from "@/src/components/design-system/DropdownMenu/DropdownMenu";import { AnnotationQueueFormDialogController } from "@/src/features/annotation-queues/components/AnnotationQueueFormDialogController";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useHasProjectAccess } from "@/src/features/rbac";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { type AnalyticsData } from "@/src/features/scores/types";import { api, reportNonTrpcError } from "@/src/utils/api";diff --git a/web/src/features/annotation-queues/components/AnnotationQueuesItem.clienttest.tsx b/web/src/features/annotation-queues/components/AnnotationQueuesItem.clienttest.tsxindex 361b70c6e2..686fb9f1f4 100644--- a/web/src/features/annotation-queues/components/AnnotationQueuesItem.clienttest.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueuesItem.clienttest.tsx@@ -50,8 +50,10 @@ vi.mock("next/router", () => ({ useRouter: () => router }));vi.mock("next-auth/react", () => ({useSession: () => ({ status: "authenticated" }),}));-vi.mock("@/src/features/rbac", () => ({ useHasProjectAccess: () => true }));-vi.mock("@/src/features/events", () => ({+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({+ useHasProjectAccess: () => true,+}));+vi.mock("@/src/features/events/hooks/useReadPath", () => ({useReadPath: () => ({ isV4: true }),}));vi.mock("@/src/components/layouts/Page", () => ({@@ -62,7 +64,7 @@ vi.mock("@/src/components/ui/tooltip", () => ({TooltipTrigger: ({ children }: { children: ReactNode }) => children,TooltipContent: () => null,}));-vi.mock("@/src/features/scores", () => ({+vi.mock("@/src/features/scores/lib/keyboardShortcuts", () => ({hasModifier: () => false,isCompleteShortcut: () => false,isInteractiveTarget: () => false,@@ -137,7 +139,7 @@ vi.mock("./shared/hooks/useAnnotationObjectData", () => ({isLoading: false,}),}));-vi.mock("@/src/features/traces", () => ({+vi.mock("@/src/features/traces/components/Trace", () => ({Trace: () => <p>Trace loaded</p>,}));vi.mock("./shared/AnnotationDrawerSection", () => ({diff --git a/web/src/features/annotation-queues/components/AnnotationQueuesItem.tsx b/web/src/features/annotation-queues/components/AnnotationQueuesItem.tsxindex 888b91ef96..1aa4c6671e 100644--- a/web/src/features/annotation-queues/components/AnnotationQueuesItem.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueuesItem.tsx@@ -1,5 +1,5 @@-import { SupportOrUpgradePage } from "@/src/ee/features/billing";-import { useHasProjectAccess } from "@/src/features/rbac";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { AnnotationQueueItemPage } from "@/src/features/annotation-queues/components/AnnotationQueueItemPage";import { api } from "@/src/utils/api";import Page from "@/src/components/layouts/Page";diff --git a/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx b/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsxindex 0868acd186..dd984614a7 100644--- a/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx@@ -5,10 +5,8 @@ import { api } from "@/src/utils/api";import { safeExtract } from "@/src/utils/map-utils";import { useQueryParams, withDefault, NumberParam } from "use-query-params";import { type RouterOutput } from "@/src/utils/types";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import {customRowHeightMenu,@@ -23,9 +21,9 @@ import { createLinkTableColumn } from "@/src/components/design-system/table/coluimport { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";import Link from "next/link";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { DeleteAnnotationQueueButton } from "@/src/features/annotation-queues/components/DeleteAnnotationQueueButton";-import { getScoreDataTypeIcon } from "@/src/features/scores";+import { getScoreDataTypeIcon } from "@/src/features/scores/lib/scoreColumns";import { type ScoreConfigDataType } from "@langfuse/shared";type RowData = {diff --git a/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx b/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsxindex da0aba2496..e7590fdd02 100644--- a/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx+++ b/web/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx@@ -1,8 +1,8 @@import { type ButtonProps } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Edit, Pen, PlusIcon } from "@langfuse/icons";import { api } from "@/src/utils/api";-import { useEntitlementLimit } from "@/src/features/entitlements";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";import { ActionButton } from "@/src/components/ActionButton";import { IconOnlyButton } from "@/src/components/IconOnlyButton";import { AnnotationQueueFormDialogController } from "@/src/features/annotation-queues/components/AnnotationQueueFormDialogController";diff --git a/web/src/features/annotation-queues/components/QueueScoreConfigFields.tsx b/web/src/features/annotation-queues/components/QueueScoreConfigFields.tsxindex c029e0d366..6621ec206f 100644--- a/web/src/features/annotation-queues/components/QueueScoreConfigFields.tsx+++ b/web/src/features/annotation-queues/components/QueueScoreConfigFields.tsx@@ -2,7 +2,7 @@ import { type ScoreConfigDomain } from "@langfuse/shared";import {CreateScoreConfigDialogController,EditScoreConfigDialogController,-} from "@/src/features/score-configs";+} from "@/src/features/score-configs/components/UpsertScoreConfigDialogController";import { AnnotationQueueScoreConfigEditor } from "./AnnotationQueueScoreConfigEditor";export function QueueScoreConfigFields({diff --git a/web/src/features/annotation-queues/components/UserAssignmentSection.tsx b/web/src/features/annotation-queues/components/UserAssignmentSection.tsxindex 3aa04d71e4..34254259f8 100644--- a/web/src/features/annotation-queues/components/UserAssignmentSection.tsx+++ b/web/src/features/annotation-queues/components/UserAssignmentSection.tsx@@ -1,11 +1,11 @@import { api } from "@/src/utils/api";import { MoreHorizontal, X } from "@langfuse/icons";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Button } from "@/src/components/ui/button";import { MultiSelectCombobox } from "@/src/components/ui/MultiSelectCombobox";import { useUserSearch } from "@/src/hooks/useUserSearch";import { useSelectedUsers } from "@/src/features/annotation-queues/hooks/useSelectedUsers";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { useRef } from "react";interface UserAssignmentSectionProps {diff --git a/web/src/features/annotation-queues/components/processors/SessionAnnotationProcessor.tsx b/web/src/features/annotation-queues/components/processors/SessionAnnotationProcessor.tsxindex ec9754d988..1cfae8c11c 100644--- a/web/src/features/annotation-queues/components/processors/SessionAnnotationProcessor.tsx+++ b/web/src/features/annotation-queues/components/processors/SessionAnnotationProcessor.tsx@@ -4,25 +4,23 @@ import {} from "@langfuse/shared";import { AnnotationDrawerSection } from "../shared/AnnotationDrawerSection";import { AnnotationProcessingLayout } from "../shared/AnnotationProcessingLayout";-import {- SessionIO,- LazyTraceEventsRow,- asCommentCounts,-} from "@/src/features/sessions";+import { SessionIO } from "@/src/features/sessions/SessionPages";+import { LazyTraceEventsRow } from "@/src/features/sessions/TraceEventsRow";+import { asCommentCounts } from "@/src/features/sessions/sessionDetailPageTypes";import { useState, useMemo, useCallback } from "react";import { Button } from "@/src/components/ui/button";import { Button as DsButton } from "@/src/components/design-system/Button/Button";import { ActionButtonCountBadge } from "@/src/components/ui/ActionButtonCountBadge";import { ItemBadge } from "@/src/components/ItemBadge";-import { CopyIdsPopover } from "@/src/features/traces";+import { CopyIdsPopover } from "@/src/features/traces/components/CopyIdsPopover";import { Badge } from "@/src/components/design-system/Badge/Badge";import { Separator } from "@/src/components/ui/separator";import Link from "next/link";import { Card } from "@/src/components/ui/card";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { api, shouldRetryResourceQuery } from "@/src/utils/api";import { JsonSkeleton } from "@/src/components/ui/CodeJsonViewer";-import { CommentDrawerController } from "@/src/features/comments";+import { CommentDrawerController } from "@/src/features/comments/CommentDrawerController";import { getNumberFromMap } from "@/src/utils/map-utils";import { MessageSquare, MessageSquareOff } from "@langfuse/icons";diff --git a/web/src/features/annotation-queues/components/processors/TraceAnnotationProcessor.tsx b/web/src/features/annotation-queues/components/processors/TraceAnnotationProcessor.tsxindex a8fcef7467..138c7f6483 100644--- a/web/src/features/annotation-queues/components/processors/TraceAnnotationProcessor.tsx+++ b/web/src/features/annotation-queues/components/processors/TraceAnnotationProcessor.tsx@@ -1,5 +1,5 @@-import { useReadPath } from "@/src/features/events";-import { Trace } from "@/src/features/traces";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { Trace } from "@/src/features/traces/components/Trace";import {type AnnotationQueueItem,type ScoreConfigDomain,diff --git a/web/src/features/annotation-queues/components/shared/AnnotationDrawerSection.tsx b/web/src/features/annotation-queues/components/shared/AnnotationDrawerSection.tsxindex d693265a84..0a692b62a6 100644--- a/web/src/features/annotation-queues/components/shared/AnnotationDrawerSection.tsx+++ b/web/src/features/annotation-queues/components/shared/AnnotationDrawerSection.tsx@@ -1,5 +1,6 @@import { Card } from "@/src/components/ui/card";-import { AnnotationForm, type ScoreTarget } from "@/src/features/scores";+import { AnnotationForm } from "@/src/features/scores/components/AnnotationForm";+import type { ScoreTarget } from "@/src/features/scores/types";import {type AnnotationQueueItem,type ScoreDomain,diff --git a/web/src/features/annotation-queues/components/shared/CommentsSection.tsx b/web/src/features/annotation-queues/components/shared/CommentsSection.tsxindex 4533f7cdd1..84e97f83d0 100644--- a/web/src/features/annotation-queues/components/shared/CommentsSection.tsx+++ b/web/src/features/annotation-queues/components/shared/CommentsSection.tsx@@ -1,4 +1,4 @@-import { CommentList } from "@/src/features/comments";+import { CommentList } from "@/src/features/comments/CommentList";import { type AnnotationQueueObjectType } from "@langfuse/shared";interface CommentsSectionProps {diff --git a/web/src/features/annotation-queues/components/shared/hooks/useAnnotationObjectData.ts b/web/src/features/annotation-queues/components/shared/hooks/useAnnotationObjectData.tsindex 8d23dc1da2..0fc16d1e50 100644--- a/web/src/features/annotation-queues/components/shared/hooks/useAnnotationObjectData.ts+++ b/web/src/features/annotation-queues/components/shared/hooks/useAnnotationObjectData.ts@@ -3,7 +3,8 @@ import {type AnnotationQueueItem,AnnotationQueueObjectType,} from "@langfuse/shared";-import { useEventsTraceData, useReadPath } from "@/src/features/events";+import { useEventsTraceData } from "@/src/features/events/hooks/useEventsTraceData";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";export interface ObjectDataHook<TData> {data: TData | undefined;diff --git a/web/src/features/annotation-queues/hooks/useSelectedUsers.ts b/web/src/features/annotation-queues/hooks/useSelectedUsers.tsindex b9bfe362a3..613dffd9fb 100644--- a/web/src/features/annotation-queues/hooks/useSelectedUsers.ts+++ b/web/src/features/annotation-queues/hooks/useSelectedUsers.ts@@ -1,5 +1,5 @@import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";interface UseSelectedUsersProps {projectId: string;diff --git a/web/src/features/annotation-queues/index.ts b/web/src/features/annotation-queues/index.tsdeleted file mode 100644index dbc34bdedc..0000000000--- a/web/src/features/annotation-queues/index.ts+++ /dev/null@@ -1,12 +0,0 @@-// The annotation-queues feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-//-// `server/` is a separate door. queue routers stay a direct import from the-// tRPC root. Page modules and AnnotationQueuesItem stay page-shim deep-// imports.-export { AddTracesToAnnotationQueueDialogController } from "@/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController";-export { AnnotationQueueItemCountBadge } from "@/src/features/annotation-queues/components/AnnotationQueueItemCountBadge";-export { AnnotationQueueItemDropdownMenuController } from "@/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController";-export { AnnotationQueueSubmenuItemController } from "@/src/features/annotation-queues/components/AnnotationQueueSubmenuItemController";-export { CreateOrEditAnnotationQueueButton } from "@/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton";-export { CommentsSection } from "@/src/features/annotation-queues/components/shared/CommentsSection";diff --git a/web/src/features/annotation-queues/pages/AnnotationQueues.tsx b/web/src/features/annotation-queues/pages/AnnotationQueues.tsxindex 25ddce2739..cc3c2d50f9 100644--- a/web/src/features/annotation-queues/pages/AnnotationQueues.tsx+++ b/web/src/features/annotation-queues/pages/AnnotationQueues.tsx@@ -1,7 +1,7 @@import { useRouter } from "next/router";import { AnnotationQueuesTable } from "@/src/features/annotation-queues/components/AnnotationQueuesTable";-import { useHasProjectAccess } from "@/src/features/rbac";-import { SupportOrUpgradePage } from "@/src/ee/features/billing";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";import Page from "@/src/components/layouts/Page";import { AnnotationQueuesOnboarding } from "@/src/components/onboarding/AnnotationQueuesOnboarding";import { api } from "@/src/utils/api";diff --git a/web/src/features/annotation-queues/pages/QueueItems.tsx b/web/src/features/annotation-queues/pages/QueueItems.tsxindex 2d4b9d85ea..95a8e91936 100644--- a/web/src/features/annotation-queues/pages/QueueItems.tsx+++ b/web/src/features/annotation-queues/pages/QueueItems.tsx@@ -3,8 +3,8 @@ import { useState } from "react";import { AnnotationQueueItemsTable } from "@/src/features/annotation-queues/components/AnnotationQueueItemsTable";import { Button } from "@/src/components/design-system/Button/Button";import { ClipboardPen, Lock } from "@langfuse/icons";-import { useHasProjectAccess } from "@/src/features/rbac";-import { SupportOrUpgradePage } from "@/src/ee/features/billing";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";import Page from "@/src/components/layouts/Page";import {SidePanel,diff --git a/web/src/features/annotation-queues/server/annotationQueueAssignmentsRouter.ts b/web/src/features/annotation-queues/server/annotationQueueAssignmentsRouter.tsindex fba46a6792..cd5efa9e4d 100644--- a/web/src/features/annotation-queues/server/annotationQueueAssignmentsRouter.ts+++ b/web/src/features/annotation-queues/server/annotationQueueAssignmentsRouter.ts@@ -1,5 +1,5 @@-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/annotation-queues/server/annotationQueueItemsRouter.ts b/web/src/features/annotation-queues/server/annotationQueueItemsRouter.tsindex 85ef2a8a8b..dc126b0bae 100644--- a/web/src/features/annotation-queues/server/annotationQueueItemsRouter.ts+++ b/web/src/features/annotation-queues/server/annotationQueueItemsRouter.ts@@ -1,6 +1,6 @@-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";-import { createBatchActionJob } from "@/src/features/table/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { createBatchActionJob } from "@/src/features/table/server/createBatchActionJob";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/annotation-queues/server/annotationQueuesRouter.ts b/web/src/features/annotation-queues/server/annotationQueuesRouter.tsindex dd1c9f9725..eb4573460e 100644--- a/web/src/features/annotation-queues/server/annotationQueuesRouter.ts+++ b/web/src/features/annotation-queues/server/annotationQueuesRouter.ts@@ -1,6 +1,6 @@import { env } from "@/src/env.mjs";-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/annotation-queues/server/index.ts b/web/src/features/annotation-queues/server/index.tsdeleted file mode 100644index 640e57cc84..0000000000--- a/web/src/features/annotation-queues/server/index.ts+++ /dev/null@@ -1,16 +0,0 @@-// The annotation-queues feature's public server surface (RFC rules 8 and 10).-// queueRouter / queueItemRouter / queueAssignmentRouter stay a direct import-// from the tRPC root, which is not a feature.-export {- createAnnotationQueueAssignmentForApi,- createAnnotationQueueForApi,- createAnnotationQueueItemForApi,- deleteAnnotationQueueAssignment,- deleteAnnotationQueueAssignmentForApi,- deleteAnnotationQueueItemForApi,- getAnnotationQueueForApi,- getAnnotationQueueItemForApi,- listAnnotationQueueItemsForApi,- listAnnotationQueuesForApi,- updateAnnotationQueueItemForApi,-} from "@/src/features/annotation-queues/server/publicAnnotationQueueService";diff --git a/web/src/features/annotation-queues/server/publicAnnotationQueueService.ts b/web/src/features/annotation-queues/server/publicAnnotationQueueService.tsindex ea48c3e344..ea39b3d59e 100644--- a/web/src/features/annotation-queues/server/publicAnnotationQueueService.ts+++ b/web/src/features/annotation-queues/server/publicAnnotationQueueService.ts@@ -1,18 +1,18 @@-import { auditLog } from "@/src/features/audit-logs/server";-import {- type AnnotationQueue,- type AnnotationQueueItem,- type CreateAnnotationQueueAssignmentBody,- type CreateAnnotationQueueBody,- type CreateAnnotationQueueItemBody,- type DeleteAnnotationQueueAssignmentBody,- type DeleteAnnotationQueueItemQuery,- type GetAnnotationQueueByIdQuery,- type GetAnnotationQueueItemByIdQuery,- type GetAnnotationQueueItemsQuery,- type GetAnnotationQueuesQuery,- type UpdateAnnotationQueueItemBody,-} from "@/src/features/public-api/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import type {+ AnnotationQueue,+ AnnotationQueueItem,+ CreateAnnotationQueueAssignmentBody,+ CreateAnnotationQueueBody,+ CreateAnnotationQueueItemBody,+ DeleteAnnotationQueueAssignmentBody,+ DeleteAnnotationQueueItemQuery,+ GetAnnotationQueueByIdQuery,+ GetAnnotationQueueItemByIdQuery,+ GetAnnotationQueueItemsQuery,+ GetAnnotationQueuesQuery,+ UpdateAnnotationQueueItemBody,+} from "@/src/features/public-api/types/annotation-queues";import {AnnotationQueueStatus,InvalidRequestError,diff --git a/web/src/features/apiKey/index.ts b/web/src/features/apiKey/index.tsdeleted file mode 100644index 128b8c90eb..0000000000--- a/web/src/features/apiKey/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export { ApiKeyExpirationInput } from "@/src/features/apiKey/components/ApiKeyExpirationInput/ApiKeyExpirationInput";-export type { ApiKeyExpirationPreset } from "@/src/features/apiKey/constants/apiKeyExpirationOptions";-export { resolveApiKeyExpiration } from "@/src/features/apiKey/fns/resolveApiKeyExpiration";-export { isApiKeyExpired } from "@/src/features/apiKey/helpers/isApiKeyExpired";diff --git a/web/src/features/apiKey/server/index.ts b/web/src/features/apiKey/server/index.tsdeleted file mode 100644index d60f22b6bc..0000000000--- a/web/src/features/apiKey/server/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export {- Authenticator,- authenticator,-} from "@/src/features/apiKey/authenticator";diff --git a/web/src/features/audit-logs/isAuditLogEnabled.ts b/web/src/features/audit-logs/isAuditLogEnabled.tsindex 3585e8ed8c..f84dffdfd2 100644--- a/web/src/features/audit-logs/isAuditLogEnabled.ts+++ b/web/src/features/audit-logs/isAuditLogEnabled.ts@@ -1,8 +1,6 @@import { env } from "@/src/env.mjs";-import {- getSelfHostedInstancePlanServerSide,- hasEntitlementBasedOnPlan,-} from "@/src/features/entitlements/server";+import { getSelfHostedInstancePlanServerSide } from "@/src/features/entitlements/server/getPlan";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";/*** Whether audit log records may be persisted on this instance.diff --git a/web/src/features/audit-logs/server/index.ts b/web/src/features/audit-logs/server/index.tsdeleted file mode 100644index ed0e4c3d77..0000000000--- a/web/src/features/audit-logs/server/index.ts+++ /dev/null@@ -1,10 +0,0 @@-// The audit-logs feature's server surface (RFC rule 9, amended). auditLog-// writes through Prisma, so it has no client-safe surface: every caller is-// server code and reaches it through here.-export {- auditLog,- toApiKeyActor,- toUserActor,- type AuditLogActor,-} from "@/src/features/audit-logs/auditLog";-export { getAuditRequestContext } from "@/src/features/audit-logs/server/getAuditRequestContext";diff --git a/web/src/features/auth-credentials/components/RequestResetPasswordEmailButton.clienttest.tsx b/web/src/features/auth-credentials/components/RequestResetPasswordEmailButton.clienttest.tsxindex e7822ef2a1..610c47a2cf 100644--- a/web/src/features/auth-credentials/components/RequestResetPasswordEmailButton.clienttest.tsx+++ b/web/src/features/auth-credentials/components/RequestResetPasswordEmailButton.clienttest.tsx@@ -11,7 +11,7 @@ vi.mock("next-auth/react", () => ({useSession: () => ({ status: "unauthenticated", data: null }),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));diff --git a/web/src/features/auth-credentials/components/RequestResetPasswordEmailButton.tsx b/web/src/features/auth-credentials/components/RequestResetPasswordEmailButton.tsxindex 3cc53fa275..1905c4be64 100644--- a/web/src/features/auth-credentials/components/RequestResetPasswordEmailButton.tsx+++ b/web/src/features/auth-credentials/components/RequestResetPasswordEmailButton.tsx@@ -2,7 +2,7 @@ import { signIn, useSession } from "next-auth/react";import { Button } from "@/src/components/ui/button";import { useEffect, useRef, useState } from "react";import { z } from "zod";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { env } from "@/src/env.mjs";import {TURNSTILE_ACTIONS,diff --git a/web/src/features/auth-credentials/components/ResetPasswordPage.captcha.clienttest.tsx b/web/src/features/auth-credentials/components/ResetPasswordPage.captcha.clienttest.tsxindex 266173d8f3..af69c4c2cd 100644--- a/web/src/features/auth-credentials/components/ResetPasswordPage.captcha.clienttest.tsx+++ b/web/src/features/auth-credentials/components/ResetPasswordPage.captcha.clienttest.tsx@@ -32,11 +32,11 @@ vi.mock("@/src/utils/api", () => ({},}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));-vi.mock("@/src/features/organizations", () => ({+vi.mock("@/src/features/organizations/hooks", () => ({useLangfuseCloudRegion: () => ({isLangfuseCloud: false,region: undefined,diff --git a/web/src/features/auth-credentials/components/ResetPasswordPage.tsx b/web/src/features/auth-credentials/components/ResetPasswordPage.tsxindex 2751e541ca..552580c478 100644--- a/web/src/features/auth-credentials/components/ResetPasswordPage.tsx+++ b/web/src/features/auth-credentials/components/ResetPasswordPage.tsx@@ -23,9 +23,9 @@ import { RequestResetPasswordEmailButton } from "@/src/features/auth-credentialsimport { TRPCClientError } from "@trpc/client";import Link from "next/link";import { ErrorPage } from "@/src/components/error-page";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { passwordSchema } from "@/src/features/auth";-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { passwordSchema } from "@/src/features/auth/lib/signupSchema";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { PASSWORD_SETUP_EMAIL_STORAGE_KEY } from "@/src/features/auth-credentials/lib/credentialsUtils";import { getOnboardingTargetPath } from "@/src/features/onboarding/lib/demoCallbackRedirect";import { env } from "@/src/env.mjs";diff --git a/web/src/features/auth-credentials/index.ts b/web/src/features/auth-credentials/index.tsdeleted file mode 100644index ba1195e9db..0000000000--- a/web/src/features/auth-credentials/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export {- isEmailVerificationRequired,- PASSWORD_SETUP_EMAIL_STORAGE_KEY,-} from "@/src/features/auth-credentials/lib/credentialsUtils";diff --git a/web/src/features/auth-credentials/lib/credentialsServerUtils.ts b/web/src/features/auth-credentials/lib/credentialsServerUtils.tsindex 49a2c3b9cd..9d6f053c26 100644--- a/web/src/features/auth-credentials/lib/credentialsServerUtils.ts+++ b/web/src/features/auth-credentials/lib/credentialsServerUtils.ts@@ -1,7 +1,7 @@import { createHash } from "crypto";import { createProjectMembershipsOnSignup } from "@/src/features/auth/lib/createProjectMembershipsOnSignup";import { advanceSessionsExpiredAtForEmail } from "@/src/features/auth/lib/sessionExpiration";-import type { AdClickIds } from "@/src/features/auth";+import type { AdClickIds } from "@/src/features/auth/lib/signupAttribution";import { env } from "@/src/env.mjs";import { hashPassword } from "@/src/features/auth-credentials/lib/passwordHash";import { prisma } from "@langfuse/shared/src/db";diff --git a/web/src/features/auth-credentials/server/signupApiHandler.ts b/web/src/features/auth-credentials/server/signupApiHandler.tsindex 51482164ea..19caae5429 100644--- a/web/src/features/auth-credentials/server/signupApiHandler.ts+++ b/web/src/features/auth-credentials/server/signupApiHandler.ts@@ -11,7 +11,7 @@ import {} from "@/src/features/auth/server/verifyTurnstile";import { getAdClickIdsFromRequest } from "@/src/features/auth/lib/signupAttribution";import { signupSchema } from "@/src/features/auth/lib/signupSchema";-import { getSsoAuthProviderIdForDomain } from "@/src/ee/features/multi-tenant-sso/server";+import { getSsoAuthProviderIdForDomain } from "@/src/ee/features/multi-tenant-sso/utils";import type { NextApiRequest, NextApiResponse } from "next";import { logger } from "@langfuse/shared/src/server";import { isEmailVerificationRequired } from "@/src/features/auth-credentials/lib/credentialsUtils";diff --git a/web/src/features/auth/SignInPage.tsx b/web/src/features/auth/SignInPage.tsxindex 2d7b34f210..54ad719739 100644--- a/web/src/features/auth/SignInPage.tsx+++ b/web/src/features/auth/SignInPage.tsx@@ -42,11 +42,11 @@ import {isJsonParseSyntaxError,} from "@/src/features/auth/lib/expectedAuthErrors";import { captureUnknownError } from "@/src/utils/captureUnknownError";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import useLocalStorage from "@/src/components/useLocalStorage";import { AuthProviderButton } from "@/src/features/auth/components/AuthProviderButton";import { cn } from "@/src/utils/tailwind";-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { getSafeRedirectPath } from "@/src/utils/redirect";import { Spinner } from "@/src/components/layouts/Spinner";import {diff --git a/web/src/features/auth/SignUpPage.clienttest.tsx b/web/src/features/auth/SignUpPage.clienttest.tsxindex f55117b40f..560fc64706 100644--- a/web/src/features/auth/SignUpPage.clienttest.tsx+++ b/web/src/features/auth/SignUpPage.clienttest.tsx@@ -27,7 +27,7 @@ vi.mock("next/router", () => ({}),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));diff --git a/web/src/features/auth/SignUpPage.tsx b/web/src/features/auth/SignUpPage.tsxindex 234c1e3901..d4bc43c261 100644--- a/web/src/features/auth/SignUpPage.tsx+++ b/web/src/features/auth/SignUpPage.tsx@@ -26,15 +26,15 @@ import {type PageProps,} from "@/src/features/auth/SignInPage";import { PasswordInput } from "@/src/components/design-system/PasswordInput/PasswordInput";-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { useRouter } from "next/router";import { getSafeRedirectPath } from "@/src/utils/redirect";import { reportError } from "@/src/utils/reportError";import { isJsonParseSyntaxError } from "@/src/features/auth/lib/expectedAuthErrors";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import useLocalStorage from "@/src/components/useLocalStorage";import { noUrlCheck, StringNoHTMLNonEmpty } from "@langfuse/shared";-import { PASSWORD_SETUP_EMAIL_STORAGE_KEY } from "@/src/features/auth-credentials";+import { PASSWORD_SETUP_EMAIL_STORAGE_KEY } from "@/src/features/auth-credentials/lib/credentialsUtils";import {getOnboardingTargetPath,getSignupCallbackUrl,diff --git a/web/src/features/auth/components/CloudRegionPicker.stories.tsx b/web/src/features/auth/components/CloudRegionPicker.stories.tsxindex 84dbffdb2f..ffe9b209f6 100644--- a/web/src/features/auth/components/CloudRegionPicker.stories.tsx+++ b/web/src/features/auth/components/CloudRegionPicker.stories.tsx@@ -1,5 +1,5 @@import preview from "../../../../.storybook/preview";-import { getAvailableCloudRegionOptions } from "@/src/features/organizations";+import { getAvailableCloudRegionOptions } from "@/src/features/organizations/cloudRegions";import { useState } from "react";import { CloudRegionPicker } from "./CloudRegionPicker";diff --git a/web/src/features/auth/components/CloudRegionPicker.tsx b/web/src/features/auth/components/CloudRegionPicker.tsxindex 257b2d4463..a936491014 100644--- a/web/src/features/auth/components/CloudRegionPicker.tsx+++ b/web/src/features/auth/components/CloudRegionPicker.tsx@@ -14,7 +14,7 @@ import {SelectItem,SelectTrigger,} from "@/src/components/ui/select";-import type { CloudRegion } from "@/src/features/organizations";+import type { CloudRegion } from "@/src/features/organizations/cloudRegions";export function CloudRegionPicker({regions,diff --git a/web/src/features/auth/components/CloudRegionSwitch.tsx b/web/src/features/auth/components/CloudRegionSwitch.tsxindex b4076b30fd..6dcacf8c5a 100644--- a/web/src/features/auth/components/CloudRegionSwitch.tsx+++ b/web/src/features/auth/components/CloudRegionSwitch.tsx@@ -1,10 +1,8 @@import { env } from "@/src/env.mjs";import { CloudRegionPicker } from "@/src/features/auth/components/CloudRegionPicker";-import {- getAvailableCloudRegionOptions,- useLangfuseCloudRegion,-} from "@/src/features/organizations";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { getAvailableCloudRegionOptions } from "@/src/features/organizations/cloudRegions";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export function CloudRegionSwitch({isSignUpPage,diff --git a/web/src/features/auth/index.ts b/web/src/features/auth/index.tsdeleted file mode 100644index c713f4c1c4..0000000000--- a/web/src/features/auth/index.ts+++ /dev/null@@ -1,11 +0,0 @@-// The auth feature's public client surface (RFC rule 8): the client-safe half-// only — the session hook and the zod schemas shared with forms.-//-// policy/, createProjectMembershipsOnSignup, signup attribution, and the-// enterprise SSO constant stay deep imports: server callers must not enter-// this client door (Turbopack RSC), and nothing else imports them through here.-export { useIsAuthenticatedAndProjectMember } from "@/src/features/auth/hooks";-export { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";-export { projectRetentionSchema } from "@/src/features/auth/lib/projectRetentionSchema";-export type { AdClickIds } from "@/src/features/auth/lib/signupAttribution";-export { passwordSchema } from "@/src/features/auth/lib/signupSchema";diff --git a/web/src/features/auth/lib/createProjectMembershipsOnSignup.ts b/web/src/features/auth/lib/createProjectMembershipsOnSignup.tsindex a5c5ecb313..1655dc239b 100644--- a/web/src/features/auth/lib/createProjectMembershipsOnSignup.ts+++ b/web/src/features/auth/lib/createProjectMembershipsOnSignup.ts@@ -2,14 +2,12 @@ import { env } from "@/src/env.mjs";import { prisma, Role } from "@langfuse/shared/src/db";import { logger } from "@langfuse/shared/src/server";import { ServerPosthog } from "@/src/features/posthog-analytics/ServerPosthog";-import {- getOrganizationPlanServerSide,- hasEntitlementBasedOnPlan,-} from "@/src/features/entitlements/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import { shouldAutoEnableV4 } from "@/src/features/events/lib/v4Rollout";-import { getSfdcService } from "@/src/ee/features/sfdc-sync/server";-import { canCreateOrganizations } from "@/src/features/organizations/server";-import { provisionStarterOrganizationForNewUser } from "@/src/features/onboarding/server";+import { getSfdcService } from "@/src/ee/features/sfdc-sync/server/sfdcService";+import { canCreateOrganizations } from "@/src/features/organizations/server/canCreateOrganizations";+import { provisionStarterOrganizationForNewUser } from "@/src/features/onboarding/server/onboardingService";import { projectRoleAccessRights } from "@langfuse/shared";import { type AdClickIds } from "@/src/features/auth/lib/signupAttribution";diff --git a/web/src/features/auth/lib/signOut.ts b/web/src/features/auth/lib/signOut.tsindex 41f3014746..a32634fac6 100644--- a/web/src/features/auth/lib/signOut.ts+++ b/web/src/features/auth/lib/signOut.ts@@ -1,7 +1,7 @@import { signOut } from "next-auth/react";import posthog from "posthog-js";import { env } from "@/src/env.mjs";-import { isPostHogClientEnabled } from "@/src/features/posthog-analytics";+import { isPostHogClientEnabled } from "@/src/features/posthog-analytics/productAnalyticsAvailability";import { clearV4BetaEnabledSentryTag } from "@/src/utils/sentryV4BetaTag";/**diff --git a/web/src/features/auth/policy/contextResolver.ts b/web/src/features/auth/policy/contextResolver.tsindex 33a994944a..7a15d59f34 100644--- a/web/src/features/auth/policy/contextResolver.ts+++ b/web/src/features/auth/policy/contextResolver.ts@@ -16,7 +16,7 @@ import {import { assignRole } from "@langfuse/shared/rbac/server";import { getRolesForPrincipal } from "@/src/features/rbac/getRolesForPrincipal";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import {OrganizationRepository,type GetOrganizationResult,diff --git a/web/src/features/auth/server/getSignInPageServerSideProps.ts b/web/src/features/auth/server/getSignInPageServerSideProps.tsindex a213e5030f..ffd2c1f85d 100644--- a/web/src/features/auth/server/getSignInPageServerSideProps.ts+++ b/web/src/features/auth/server/getSignInPageServerSideProps.ts@@ -1,8 +1,8 @@/* eslint-disable no-nested-ternary */import { type GetServerSideProps } from "next";import { env } from "@/src/env.mjs";-import { isAnySsoConfigured } from "@/src/ee/features/multi-tenant-sso/server";-import { isEmailVerificationRequired } from "@/src/features/auth-credentials";+import { isAnySsoConfigured } from "@/src/ee/features/multi-tenant-sso/utils";+import { isEmailVerificationRequired } from "@/src/features/auth-credentials/lib/credentialsUtils";import { type PageProps } from "@/src/features/auth/SignInPage";// Also used in src/pages/auth/sign-up.tsx via the pages/auth/sign-in shim.diff --git a/web/src/features/automations/components/AutomationButton.tsx b/web/src/features/automations/components/AutomationButton.tsxindex 1cf8fc065c..f53bff2c05 100644--- a/web/src/features/automations/components/AutomationButton.tsx+++ b/web/src/features/automations/components/AutomationButton.tsx@@ -1,5 +1,5 @@import { ActionButton } from "@/src/components/ActionButton";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Zap } from "@langfuse/icons";import { api } from "@/src/utils/api";import { Spinner } from "@/src/components/design-system/Spinner/Spinner";diff --git a/web/src/features/automations/components/AutomationForm.clienttest.tsx b/web/src/features/automations/components/AutomationForm.clienttest.tsxindex fc13987481..d2190dbb25 100644--- a/web/src/features/automations/components/AutomationForm.clienttest.tsx+++ b/web/src/features/automations/components/AutomationForm.clienttest.tsx@@ -69,7 +69,7 @@ vi.mock("@/src/features/organizations/hooks", () => ({useLangfuseCloudRegion: () => ({ isLangfuseCloud: true, region: "US" }),}));-vi.mock("@/src/features/events", () => ({+vi.mock("@/src/features/events/hooks/useReadPath", () => ({useReadPath: () => ({ isV4: true }),}));diff --git a/web/src/features/automations/components/AutomationForm.tsx b/web/src/features/automations/components/AutomationForm.tsxindex 1d98274e72..2a5a2b13e9 100644--- a/web/src/features/automations/components/AutomationForm.tsx+++ b/web/src/features/automations/components/AutomationForm.tsx@@ -1,5 +1,6 @@/* eslint-disable no-nested-ternary */-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import React from "react";import {Card,@@ -48,11 +49,12 @@ import {PagerDutyRegionSchema,PagerDutyRoutingKeySchema,} from "@langfuse/shared/pagerduty";-import { InlineFilterBuilder, MultiSelect } from "@/src/features/filters";+import { InlineFilterBuilder } from "@/src/features/filters/components/filter-builder";+import { MultiSelect } from "@/src/features/filters/components/MultiSelect";import { DeleteAutomationDialogController } from "./DeleteAutomationDialogController";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useHasProjectAccess } from "@/src/features/rbac";-import { ActionHandlerRegistry } from "./actions";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { ActionHandlerRegistry } from "@/src/features/automations/components/actions/ActionHandlerRegistry";import { actionTypeLabel } from "@/src/features/automations/actionTypeLabels";import { webhookSchema } from "./actions/WebhookActionForm";import { Alert } from "@/src/components/design-system/Alert/Alert";diff --git a/web/src/features/automations/components/DeleteAutomationDialogController.tsx b/web/src/features/automations/components/DeleteAutomationDialogController.tsxindex 5c16fafc97..dbe77ff759 100644--- a/web/src/features/automations/components/DeleteAutomationDialogController.tsx+++ b/web/src/features/automations/components/DeleteAutomationDialogController.tsx@@ -1,9 +1,9 @@-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import type * as React from "react";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { DeleteAutomationDialog } from "./DeleteAutomationDialog";type DeleteAutomationDialogControllerProps = {diff --git a/web/src/features/automations/components/actions/PagerDutyActionHandler.ts b/web/src/features/automations/components/actions/PagerDutyActionHandler.tsindex 06cc87c047..18a7d688fa 100644--- a/web/src/features/automations/components/actions/PagerDutyActionHandler.ts+++ b/web/src/features/automations/components/actions/PagerDutyActionHandler.ts@@ -7,7 +7,7 @@ import {type SafePagerDutyActionConfig,} from "@langfuse/shared";import { type PagerDutyRegion } from "@langfuse/shared/pagerduty";-import { PagerDutyActionForm } from "@/src/features/pagerduty";+import { PagerDutyActionForm } from "@/src/features/pagerduty/components/PagerDutyActionForm";import { type BaseActionHandler } from "./BaseActionHandler";/** PagerDutyActionHandler wires the PagerDuty action into the automation form. */diff --git a/web/src/features/automations/components/actions/SlackActionForm.tsx b/web/src/features/automations/components/actions/SlackActionForm.tsxindex 09d84c9a7c..dbf02e4e46 100644--- a/web/src/features/automations/components/actions/SlackActionForm.tsx+++ b/web/src/features/automations/components/actions/SlackActionForm.tsx@@ -10,14 +10,15 @@ import {import { type UseFormReturn } from "react-hook-form";import { type ActionDomain, isSlackActionConfig } from "@langfuse/shared";import { api } from "@/src/utils/api";+import { SlackConnectionCard } from "@/src/features/slack/components/SlackConnectionCard";import {- SlackConnectionCard,ChannelSelector,type SlackChannel,- SlackTestMessageButton,-} from "@/src/features/slack";+} from "@/src/features/slack/components/ChannelSelector";++import { SlackTestMessageButton } from "@/src/features/slack/components/SlackTestMessageButton";import { useState } from "react";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";interface SlackActionFormProps {form: UseFormReturn<any>;diff --git a/web/src/features/automations/components/actions/WebhookActionForm.tsx b/web/src/features/automations/components/actions/WebhookActionForm.tsxindex 1703327eb2..5d6a75649a 100644--- a/web/src/features/automations/components/actions/WebhookActionForm.tsx+++ b/web/src/features/automations/components/actions/WebhookActionForm.tsx@@ -37,7 +37,7 @@ import {} from "@/src/components/ui/popover";import { WebhookSecretRender } from "../WebhookSecretRender";import { CodeSection } from "@/src/components/design-system/CodeSection/CodeSection";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { areDestinationUrlsEquivalent } from "@/src/features/automations/destinationUrl";import { cn } from "@/src/utils/tailwind";diff --git a/web/src/features/automations/components/actions/index.ts b/web/src/features/automations/components/actions/index.tsdeleted file mode 100644index 1ba92d637c..0000000000--- a/web/src/features/automations/components/actions/index.ts+++ /dev/null@@ -1 +0,0 @@-export { ActionHandlerRegistry } from "./ActionHandlerRegistry";diff --git a/web/src/features/automations/index.ts b/web/src/features/automations/index.tsdeleted file mode 100644index 9abe09559d..0000000000--- a/web/src/features/automations/index.ts+++ /dev/null@@ -1,9 +0,0 @@-// The automations feature's public client surface (RFC rule 8). Named-// re-exports only — the form, button, and webhook secret UI other-// features already imported by file path.-//-// automationsRouter and the automations page stay off this door.-export { AutomationButton } from "@/src/features/automations/components/AutomationButton";-export { AutomationForm } from "@/src/features/automations/components/AutomationForm";-export { actionTypeLabel } from "@/src/features/automations/actionTypeLabels";-export { WebhookSecretRender } from "@/src/features/automations/components/WebhookSecretRender";diff --git a/web/src/features/automations/server/router.ts b/web/src/features/automations/server/router.tsindex 7e9901eeb9..8a1ad0f484 100644--- a/web/src/features/automations/server/router.ts+++ b/web/src/features/automations/server/router.ts@@ -18,7 +18,7 @@ import {PagerDutyRoutingKeySchema,PagerDutyTestEventStepSchema,} from "@langfuse/shared/pagerduty";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { v4 } from "uuid";import {convertActionToDomain,@@ -35,11 +35,11 @@ import { processGitHubDispatchActionConfig } from "./githubDispatchHelpers";import {processPagerDutyActionConfig,sendPagerDutyTestEvent,-} from "@/src/features/pagerduty/server";+} from "@/src/features/pagerduty/server/pagerdutyHelpers";import { maskActionForViewer, processSlackActionConfig } from "./slackHelpers";import { updateTriggerEventActions } from "./automationService";import { TRPCError } from "@trpc/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";const CreateAutomationInputSchema = z.object({projectId: z.string(),diff --git a/web/src/features/background-migrations/components/RetryBackgroundMigrationPopoverController.tsx b/web/src/features/background-migrations/components/RetryBackgroundMigrationPopoverController.tsxindex 2c127b99aa..dec0ef57cd 100644--- a/web/src/features/background-migrations/components/RetryBackgroundMigrationPopoverController.tsx+++ b/web/src/features/background-migrations/components/RetryBackgroundMigrationPopoverController.tsx@@ -5,7 +5,8 @@ import type * as React from "react";import { PopoverController } from "@/src/components/ui/popover";import { Input } from "@/src/components/ui/input";import { Label } from "@/src/components/ui/label";-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";type RetryBackgroundMigrationPopoverControllerProps = {diff --git a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog.clienttest.tsx b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog.clienttest.tsxindex e8d7a6a922..5e880858e6 100644--- a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog.clienttest.tsx+++ b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog.clienttest.tsx@@ -59,7 +59,9 @@ vi.mock("@/src/utils/api", () => ({},},}));-vi.mock("@/src/features/notifications", () => ({ showErrorToast: vi.fn() }));+vi.mock("@/src/features/notifications/showErrorToast", () => ({+ showErrorToast: vi.fn(),+}));vi.mock("@/src/components/ui/Combobox", () => ({Combobox: ({ onValueChange }: { onValueChange: (value: string) => void }) => (<button onClick={() => onValueChange("dataset")}>Use dataset</button>diff --git a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog.tsx b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog.tsxindex 96e72bb8e5..4cf50018fa 100644--- a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog.tsx+++ b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog.tsx@@ -11,7 +11,7 @@ import {DialogBody,} from "@/src/components/ui/dialog";import { api, sendAsPostOption } from "@/src/utils/api";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { DatasetCreateStep } from "./DatasetCreateStep";import { DatasetMappingEditor } from "./DatasetMappingEditor";diff --git a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/DatasetCreateStep.tsx b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/DatasetCreateStep.tsxindex ec47a63091..92e1187cc0 100644--- a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/DatasetCreateStep.tsx+++ b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/DatasetCreateStep.tsx@@ -1,4 +1,4 @@-import { DatasetForm } from "@/src/features/datasets";+import { DatasetForm } from "@/src/features/datasets/components/DatasetForm";import type { DatasetInfo } from "./types";export function DatasetCreateStep(props: {diff --git a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/MappingStep.tsx b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/MappingStep.tsxindex 479363839a..595cfaa90b 100644--- a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/MappingStep.tsx+++ b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/MappingStep.tsx@@ -1,6 +1,6 @@import { CustomMappingEditor } from "./components/CustomMappingEditor";import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";-import { DatasetSchemaHoverCard } from "@/src/features/datasets";+import { DatasetSchemaHoverCard } from "@/src/features/datasets/components/DatasetSchemaHoverCard";import type {FieldMappingConfig,MappingMode,diff --git a/web/src/features/batch-actions/components/BatchActionsSettingsPage.tsx b/web/src/features/batch-actions/components/BatchActionsSettingsPage.tsxindex 917fdd3897..22093a608f 100644--- a/web/src/features/batch-actions/components/BatchActionsSettingsPage.tsx+++ b/web/src/features/batch-actions/components/BatchActionsSettingsPage.tsx@@ -1,6 +1,6 @@import Header from "@/src/components/layouts/header";import { Alert } from "@/src/components/design-system/Alert/Alert";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ConnectedBatchActionsTable } from "./BatchActionsTable/ConnectedBatchActionsTable";export function BatchActionsSettingsPage(props: { projectId: string }) {diff --git a/web/src/features/batch-actions/components/RunEvaluationDialog/EvaluatorMappingStep.tsx b/web/src/features/batch-actions/components/RunEvaluationDialog/EvaluatorMappingStep.tsxindex 652fd691f0..bb866b3b45 100644--- a/web/src/features/batch-actions/components/RunEvaluationDialog/EvaluatorMappingStep.tsx+++ b/web/src/features/batch-actions/components/RunEvaluationDialog/EvaluatorMappingStep.tsx@@ -5,15 +5,16 @@ import type { ReactNode } from "react";import { Card, CardContent } from "@/src/components/ui/card";import { InfoTooltip } from "@/src/components/ui/InfoTooltip/InfoTooltip";import { Skeleton } from "@/src/components/ui/skeleton";-import {- EvaluatorAssignmentsEditor,- type RuleEvaluatorOption,-} from "@/src/features/evals";+import { EvaluatorAssignmentsEditor } from "@/src/features/evals/v2/components/Rules/EvaluatorAssignmentsEditor/EvaluatorAssignmentsEditor";+import type {+ RuleEvaluatorOption,+ RuleSetupStore,+} from "@/src/features/evals/v2/types/rules";import {useRuleCostEstimate,type RuleCostEstimate,} from "@/src/features/evals/v2/hooks/useRuleCostEstimate";-import type { RuleSetupStore } from "@/src/features/evals/v2/types/rules";+import { usdFormatter } from "@/src/utils/numbers";export function EvaluatorMappingStep({diff --git a/web/src/features/batch-actions/components/RunEvaluationDialog/index.clienttest.tsx b/web/src/features/batch-actions/components/RunEvaluationDialog/index.clienttest.tsxindex ba9b197bba..2e9b970b24 100644--- a/web/src/features/batch-actions/components/RunEvaluationDialog/index.clienttest.tsx+++ b/web/src/features/batch-actions/components/RunEvaluationDialog/index.clienttest.tsx@@ -42,14 +42,25 @@ vi.mock("@/src/utils/api", () => ({},},}));-vi.mock("@/src/features/notifications", () => ({+vi.mock("@/src/features/notifications/showErrorToast", () => ({showErrorToast: vi.fn(),showSuccessToast: vi.fn(),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/notifications/showSuccessToast", () => ({+ showErrorToast: vi.fn(),+ showSuccessToast: vi.fn(),+}));+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));-vi.mock("@/src/features/evals", () => ({+vi.mock(+ "@/src/features/evals/v2/fns/evaluatorTesting/buildSelectedSampleObject",+ () => ({+ buildSelectedSampleObject: () => null,+ createRuleSetupStore: () => createStore(() => ({ assignments: [] })),+ }),+);+vi.mock("@/src/features/evals/v2/stores/createRuleSetupStore", () => ({buildSelectedSampleObject: () => null,createRuleSetupStore: () => createStore(() => ({ assignments: [] })),}));diff --git a/web/src/features/batch-actions/components/RunEvaluationDialog/index.tsx b/web/src/features/batch-actions/components/RunEvaluationDialog/index.tsxindex 4738482568..6f32d16010 100644--- a/web/src/features/batch-actions/components/RunEvaluationDialog/index.tsx+++ b/web/src/features/batch-actions/components/RunEvaluationDialog/index.tsx@@ -22,7 +22,8 @@ import {import { Button } from "@/src/components/ui/button";import { Skeleton } from "@/src/components/ui/skeleton";import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { ChevronLeft, ExternalLink, Plus } from "@langfuse/icons";import {@@ -38,14 +39,12 @@ import {hasCompleteBatchEvalMappings,} from "./utils";import { BATCH_EVAL_EVALUATOR_LIMIT } from "@/src/features/batch-actions/validation";-import {- buildSelectedSampleObject,- createRuleSetupStore,-} from "@/src/features/evals";+import { buildSelectedSampleObject } from "@/src/features/evals/v2/fns/evaluatorTesting/buildSelectedSampleObject";+import { createRuleSetupStore } from "@/src/features/evals/v2/stores/createRuleSetupStore";import { coverEvaluatorPromptVariables } from "@/src/features/evals/v2/fns/variableMapping/coverEvaluatorPromptVariables";import { prepareModernRuleVariableMapping } from "@/src/features/evals/v2/fns/variableMapping/prepareModernRuleVariableMapping";import { useDebounce } from "@/src/hooks/useDebounce";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";type RunEvaluationDialogProps = {projectId: string;diff --git a/web/src/features/batch-actions/index.ts b/web/src/features/batch-actions/index.tsdeleted file mode 100644index 88cc080731..0000000000--- a/web/src/features/batch-actions/index.ts+++ /dev/null@@ -1,5 +0,0 @@-// The batch-actions feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export { AddObservationsToDatasetDialog } from "@/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog";-export { BatchActionsSettingsPage } from "@/src/features/batch-actions/components/BatchActionsSettingsPage";-export { RunEvaluationDialog } from "@/src/features/batch-actions/components/RunEvaluationDialog";diff --git a/web/src/features/batch-actions/server/addToDatasetRouter.ts b/web/src/features/batch-actions/server/addToDatasetRouter.tsindex c9bd99aa56..61f4e724db 100644--- a/web/src/features/batch-actions/server/addToDatasetRouter.ts+++ b/web/src/features/batch-actions/server/addToDatasetRouter.ts@@ -1,6 +1,6 @@/* eslint-disable no-nested-ternary */-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,@@ -23,7 +23,7 @@ import {} from "@langfuse/shared";import { env } from "@/src/env.mjs";import { CreateObservationAddToDatasetActionSchema } from "../validation";-import { assertLegacyTracingIoSearchCanCreateBatchJob } from "@/src/features/traces/server";+import { assertLegacyTracingIoSearchCanCreateBatchJob } from "@/src/features/traces/server/legacyIoSearch";const MAX_BATCH_ADD_TO_DATASET_ITEMS = 1000;diff --git a/web/src/features/batch-actions/server/batchActionRouter.ts b/web/src/features/batch-actions/server/batchActionRouter.tsindex 55c4fb0bad..f29cef2a7b 100644--- a/web/src/features/batch-actions/server/batchActionRouter.ts+++ b/web/src/features/batch-actions/server/batchActionRouter.ts@@ -1,4 +1,4 @@-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/batch-actions/server/batchEvaluationService.ts b/web/src/features/batch-actions/server/batchEvaluationService.tsindex 437c03eb30..0583d6f39a 100644--- a/web/src/features/batch-actions/server/batchEvaluationService.ts+++ b/web/src/features/batch-actions/server/batchEvaluationService.ts@@ -18,7 +18,7 @@ import {logger,} from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";import { batchEligibleEvaluatorWhere } from "@/src/features/evals/v2/server/evaluators/evaluatorRepository";import type { CreateObservationBatchEvaluationActionSchema } from "../validation";import { prepareBatchEvalEvaluatorMappings } from "./prepareBatchEvalEvaluatorMappings";diff --git a/web/src/features/batch-actions/server/runEvaluationRouter.ts b/web/src/features/batch-actions/server/runEvaluationRouter.tsindex cad421f9a5..2d27d6be26 100644--- a/web/src/features/batch-actions/server/runEvaluationRouter.ts+++ b/web/src/features/batch-actions/server/runEvaluationRouter.ts@@ -1,5 +1,5 @@-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/batch-exports/components/BatchExportsSettingsPage.tsx b/web/src/features/batch-exports/components/BatchExportsSettingsPage.tsxindex da2b1c35d4..20cc641e0d 100644--- a/web/src/features/batch-exports/components/BatchExportsSettingsPage.tsx+++ b/web/src/features/batch-exports/components/BatchExportsSettingsPage.tsx@@ -1,7 +1,7 @@import Header from "@/src/components/layouts/header";import { Alert } from "@/src/components/design-system/Alert/Alert";import { ConnectedBatchExportsTable } from "@/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export function BatchExportsSettingsPage(props: { projectId: string }) {const hasAccess = useHasProjectAccess({diff --git a/web/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable.tsx b/web/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable.tsxindex cf5e8604df..d80f801332 100644--- a/web/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable.tsx+++ b/web/src/features/batch-exports/components/BatchExportsTable/ConnectedBatchExportsTable.tsx@@ -3,7 +3,7 @@ import { NumberParam, useQueryParams, withDefault } from "use-query-params";import { type AsyncTableData } from "@/src/components/design-system/table/Table";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { safeExtract } from "@/src/utils/map-utils";import { BatchExportsTable, type BatchExportRow } from "./BatchExportsTable";diff --git a/web/src/features/batch-exports/index.ts b/web/src/features/batch-exports/index.tsdeleted file mode 100644index 699936e266..0000000000--- a/web/src/features/batch-exports/index.ts+++ /dev/null@@ -1 +0,0 @@-export { BatchExportsSettingsPage } from "@/src/features/batch-exports/components/BatchExportsSettingsPage";diff --git a/web/src/features/batch-exports/server/batchExport.ts b/web/src/features/batch-exports/server/batchExport.tsindex 16607d258e..d7eeae4b2c 100644--- a/web/src/features/batch-exports/server/batchExport.ts+++ b/web/src/features/batch-exports/server/batchExport.ts@@ -1,13 +1,16 @@/* eslint-disable @typescript-eslint/no-use-before-define */-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { env } from "@/src/env.mjs";import { parseBatchExportFileKeyFromUrl } from "@/src/features/batch-exports/server/batchExportFileKey";import { getBatchExportStorageServiceClient } from "@/src/features/batch-exports/server/getBatchExportStorageClient";import {hasEntitlement,throwIfNoEntitlement,-} from "@/src/features/entitlements/server";-import { hasProjectAccess, throwIfNoProjectAccess } from "@/src/features/rbac";+} from "@/src/features/entitlements/server/hasEntitlement";+import {+ hasProjectAccess,+ throwIfNoProjectAccess,+} from "@/src/features/rbac/utils/checkProjectAccess";import {type AuthedSession,createTRPCRouter,@@ -30,7 +33,7 @@ import {} from "@langfuse/shared/src/server";import { TRPCError } from "@trpc/server";import { z } from "zod";-import { assertLegacyTracingIoSearchCanCreateBatchJob } from "@/src/features/traces/server";+import { assertLegacyTracingIoSearchCanCreateBatchJob } from "@/src/features/traces/server/legacyIoSearch";// Fallback for legacy rows that predate the worker stamping expiresAt;// matches the worker's BATCH_EXPORT_DOWNLOAD_LINK_EXPIRATION_HOURS default.diff --git a/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx b/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsxindex 41ed18eae7..062ad5ca01 100644--- a/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx+++ b/web/src/features/blobstorage-integration/BlobStorageIntegrationPage.tsx@@ -4,7 +4,7 @@ import ContainerPage from "@/src/components/layouts/ContainerPage";import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";import { Button } from "@/src/components/ui/button";import { Card } from "@/src/components/ui/card";-import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations";+import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations/components/IntegrationSettingsSkeleton";import Link from "next/link";import { useRouter } from "next/router";import { BlobStorageIntegrationContainer } from "@/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer";diff --git a/web/src/features/blobstorage-integration/authorizeBlobStorageRequest.ts b/web/src/features/blobstorage-integration/authorizeBlobStorageRequest.tsindex 91883b7df0..dd942a2cc8 100644--- a/web/src/features/blobstorage-integration/authorizeBlobStorageRequest.ts+++ b/web/src/features/blobstorage-integration/authorizeBlobStorageRequest.ts@@ -3,8 +3,8 @@ import { type NextApiRequest } from "next";import { ForbiddenError } from "@langfuse/shared";import { type ApiAccessScope } from "@langfuse/shared/src/server";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import { shadowAuth } from "@/src/features/public-api/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";/** authorizeBlobStorageRequest gates a blob-storage request on an organization key and the blob-export entitlement, returning the verified scope. */export async function authorizeBlobStorageRequest(diff --git a/web/src/features/blobstorage-integration/blobstorage-integration-router.ts b/web/src/features/blobstorage-integration/blobstorage-integration-router.tsindex c59951d9a0..d0b3463d02 100644--- a/web/src/features/blobstorage-integration/blobstorage-integration-router.ts+++ b/web/src/features/blobstorage-integration/blobstorage-integration-router.ts@@ -1,8 +1,8 @@import { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,@@ -13,7 +13,7 @@ import {validateExportFieldGroups,} from "@/src/features/blobstorage-integration/validation";import { upsertBlobStorageIntegration } from "@/src/features/blobstorage-integration/service";-import { resolveExportSource } from "@/src/features/analytics-integrations/server";+import { resolveExportSource } from "@/src/features/analytics-integrations/server/exportSource";import { TRPCError } from "@trpc/server";import { type Session } from "next-auth";import { env } from "@/src/env.mjs";diff --git a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsxindex 342b8558e4..7be2b7e13c 100644--- a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx+++ b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationContainer.tsx@@ -1,11 +1,10 @@-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { useMemo } from "react";import { Button } from "@/src/components/ui/button";-import {- IntegrationSettingsSkeleton,- buildExportSourceContext,-} from "@/src/features/analytics-integrations";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations/components/IntegrationSettingsSkeleton";+import { buildExportSourceContext } from "@/src/features/analytics-integrations/exportSource";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import {@@ -14,8 +13,8 @@ import {type ExportSourceContext,} from "@langfuse/shared";import { type BlobStorageIntegrationFormSchema } from "@/src/features/blobstorage-integration/types";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useQueryProject } from "@/src/features/projects";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useQueryProject } from "@/src/features/projects/hooks";import {buildBlobStorageFormValues,toStoredFieldGroups,diff --git a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsxindex 159eb59219..4787f65642 100644--- a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx+++ b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx@@ -21,7 +21,7 @@ import {blobStorageIntegrationFormSchema,type BlobStorageIntegrationFormSchema,} from "@/src/features/blobstorage-integration/types";-import { isExportSourceSelectable } from "@/src/features/analytics-integrations";+import { isExportSourceSelectable } from "@/src/features/analytics-integrations/exportSource";import { type BlobStorageFormValues } from "@/src/features/blobstorage-integration/components/formValues";import { StorageProviderFields } from "@/src/features/blobstorage-integration/components/StorageProviderFields";import { ExportScheduleFields } from "@/src/features/blobstorage-integration/components/ExportScheduleFields";diff --git a/web/src/features/blobstorage-integration/components/ExportSourceField.tsx b/web/src/features/blobstorage-integration/components/ExportSourceField.tsxindex f4ff51c5ff..baf7011d61 100644--- a/web/src/features/blobstorage-integration/components/ExportSourceField.tsx+++ b/web/src/features/blobstorage-integration/components/ExportSourceField.tsx@@ -25,7 +25,7 @@ import {getExportSourceOptions,getExportSourceUnavailableMessage,shouldHideExportSourceSelector,-} from "@/src/features/analytics-integrations";+} from "@/src/features/analytics-integrations/exportSource";import { type BlobStorageFormControl } from "@/src/features/blobstorage-integration/components/formValues";// Export source selector plus the blocked-save alert for a persisted sourcediff --git a/web/src/features/blobstorage-integration/components/StorageProviderFields.tsx b/web/src/features/blobstorage-integration/components/StorageProviderFields.tsxindex d4336afe8a..fedab9f193 100644--- a/web/src/features/blobstorage-integration/components/StorageProviderFields.tsx+++ b/web/src/features/blobstorage-integration/components/StorageProviderFields.tsx@@ -16,7 +16,7 @@ import {BlobStorageIntegrationType,GCS_USE_DEFAULT_CREDENTIALS,} from "@langfuse/shared";-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import {type BlobStorageFormControl,type BlobStorageFormValues,diff --git a/web/src/features/blobstorage-integration/components/formValues.ts b/web/src/features/blobstorage-integration/components/formValues.tsindex 162f40e67d..5718540c6c 100644--- a/web/src/features/blobstorage-integration/components/formValues.ts+++ b/web/src/features/blobstorage-integration/components/formValues.ts@@ -16,7 +16,7 @@ import type {blobStorageIntegrationFormSchema,BlobStorageIntegrationFormSchema,} from "@/src/features/blobstorage-integration/types";-import { getExportSourceFormValue } from "@/src/features/analytics-integrations";+import { getExportSourceFormValue } from "@/src/features/analytics-integrations/exportSource";// Pre-parse (input) shape of the form; zod defaults make some fields optional.export type BlobStorageFormValues = z.input<diff --git a/web/src/features/blobstorage-integration/index.ts b/web/src/features/blobstorage-integration/index.tsdeleted file mode 100644index 3e5329e3c0..0000000000--- a/web/src/features/blobstorage-integration/index.ts+++ /dev/null@@ -1,6 +0,0 @@-export {- EXPORT_START_DATE_FUTURE_ERROR,- exportStartDateNotInFuture,- validateAzureContainerName,- validateExportFieldGroups,-} from "@/src/features/blobstorage-integration/validation";diff --git a/web/src/features/blobstorage-integration/service.ts b/web/src/features/blobstorage-integration/service.tsindex a217fbfbc1..fc360b30a2 100644--- a/web/src/features/blobstorage-integration/service.ts+++ b/web/src/features/blobstorage-integration/service.ts@@ -11,7 +11,7 @@ import {GCPServiceAccountKeySchema,GCS_USE_DEFAULT_CREDENTIALS,} from "@langfuse/shared";-import { assertPersistedExportSourceAllowed } from "@/src/features/analytics-integrations/server";+import { assertPersistedExportSourceAllowed } from "@/src/features/analytics-integrations/server/exportSource";import { isSameStorageDestination } from "@/src/features/automations/destinationUrl";import { encrypt } from "@langfuse/shared/encryption";import { env } from "@/src/env.mjs";diff --git a/web/src/features/blobstorage-integration/useBlobStorageIntegration.ts b/web/src/features/blobstorage-integration/useBlobStorageIntegration.tsindex 9ac6fa1685..45ed7964df 100644--- a/web/src/features/blobstorage-integration/useBlobStorageIntegration.ts+++ b/web/src/features/blobstorage-integration/useBlobStorageIntegration.ts@@ -1,6 +1,6 @@import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";-import { useHasEntitlement } from "@/src/features/entitlements";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import {deriveSyncStatus,diff --git a/web/src/features/chart-view-prototype/components/ChartViewPrototype.tsx b/web/src/features/chart-view-prototype/components/ChartViewPrototype.tsxindex 767ba31cf6..c0ca9330ae 100644--- a/web/src/features/chart-view-prototype/components/ChartViewPrototype.tsx+++ b/web/src/features/chart-view-prototype/components/ChartViewPrototype.tsx@@ -13,10 +13,10 @@ import {ChartTypePicker,GranularitySelect,MetricSelect,- ChartCanvas,- ChartViewPanel,- ViewModeToggle,-} from "@/src/features/chart-view";+} from "@/src/features/chart-view/components/ConfigControls";+import { ChartCanvas } from "@/src/features/chart-view/components/ChartCanvas";+import { ChartViewPanel } from "@/src/features/chart-view/components/ChartViewPanel";+import { ViewModeToggle } from "@/src/features/chart-view/components/ViewModeToggle";import {coerceConfig,DEFAULT_CONFIG,diff --git a/web/src/features/chart-view-prototype/lib/aggregate.ts b/web/src/features/chart-view-prototype/lib/aggregate.tsindex 2f9fc5328a..a01d630e26 100644--- a/web/src/features/chart-view-prototype/lib/aggregate.ts+++ b/web/src/features/chart-view-prototype/lib/aggregate.ts@@ -1,4 +1,4 @@-import type { DataPoint } from "@/src/features/widgets";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";import {type AggregationFn,type ChartViewConfig,diff --git a/web/src/features/chart-view/EventsChartView.tsx b/web/src/features/chart-view/EventsChartView.tsxindex 9de1c00193..4770b80437 100644--- a/web/src/features/chart-view/EventsChartView.tsx+++ b/web/src/features/chart-view/EventsChartView.tsx@@ -7,7 +7,7 @@ import { chartConfigToWidgetInput } from "./lib/chartConfigToWidget";import { toChartFilters } from "./lib/chartFilterCompatibility";import { ChartViewPanel } from "./components/ChartViewPanel";import { AddToDashboardButton } from "./components/AddToDashboardButton";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";/*** Production chart view for the v4 events table. Builds the observations* aggregate query from the same filters + time window the table is showing,diff --git a/web/src/features/chart-view/components/AddToDashboardButton.tsx b/web/src/features/chart-view/components/AddToDashboardButton.tsxindex 2500a22521..9817a44356 100644--- a/web/src/features/chart-view/components/AddToDashboardButton.tsx+++ b/web/src/features/chart-view/components/AddToDashboardButton.tsx@@ -3,7 +3,7 @@ import { useRouter } from "next/router";import { LayoutDashboard } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";import { api } from "@/src/utils/api";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { SelectDashboardDialog } from "@/src/features/dashboard/components/SelectDashboardDialog";import { type ChartWidgetInput } from "../lib/chartConfigToWidget";diff --git a/web/src/features/chart-view/components/ChartCanvas.tsx b/web/src/features/chart-view/components/ChartCanvas.tsxindex 39a4eb46b5..5d84334738 100644--- a/web/src/features/chart-view/components/ChartCanvas.tsx+++ b/web/src/features/chart-view/components/ChartCanvas.tsx@@ -1,12 +1,13 @@import React, { useMemo } from "react";import { BarChart3 } from "@langfuse/icons";import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";-import {- Chart,- type DataPoint,- getWidgetMissingBucketValue,-} from "@/src/features/widgets";-import { type ChartProps } from "@/src/features/widgets/chart-library/chart-props";+import { Chart } from "@/src/features/widgets/chart-library/Chart";+import type {+ DataPoint,+ ChartProps,+} from "@/src/features/widgets/chart-library/chart-props";+import { getWidgetMissingBucketValue } from "@/src/features/widgets/utils";+import { type AggregationFn } from "../types";import { isTimeSeriesChartType } from "../vocab";diff --git a/web/src/features/chart-view/components/ChartViewPanel.stories.tsx b/web/src/features/chart-view/components/ChartViewPanel.stories.tsxindex 7f67ecbdda..f562eae5b5 100644--- a/web/src/features/chart-view/components/ChartViewPanel.stories.tsx+++ b/web/src/features/chart-view/components/ChartViewPanel.stories.tsx@@ -1,6 +1,6 @@import preview from "../../../../.storybook/preview";import { fn } from "storybook/test";-import type { DataPoint } from "@/src/features/widgets";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";import { ChartViewPanel } from "./ChartViewPanel";import { DEFAULT_CONFIG } from "../vocab";diff --git a/web/src/features/chart-view/components/ChartViewPanel.tsx b/web/src/features/chart-view/components/ChartViewPanel.tsxindex bffbb65294..a5092741a4 100644--- a/web/src/features/chart-view/components/ChartViewPanel.tsx+++ b/web/src/features/chart-view/components/ChartViewPanel.tsx@@ -8,7 +8,7 @@ import {Loader2,} from "@langfuse/icons";import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";-import type { DataPoint } from "@/src/features/widgets";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";import { Button } from "@/src/components/ui/button";import { cn } from "@/src/utils/tailwind";import {diff --git a/web/src/features/chart-view/index.ts b/web/src/features/chart-view/index.tsdeleted file mode 100644index c0b5240743..0000000000--- a/web/src/features/chart-view/index.ts+++ /dev/null@@ -1,20 +0,0 @@-// The chart-view feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-//-// EventsChartView stays a page-level deep import. types, vocab, and-// chartFilterCompatibility stay off this door: the last pulls search-bar,-// and putting it (or the page) on a barrel that scores-chart-view types-// would share would load that graph into type-only consumers.-export { AddToDashboardButton } from "@/src/features/chart-view/components/AddToDashboardButton";-export { ChartCanvas } from "@/src/features/chart-view/components/ChartCanvas";-export { ChartViewPanel } from "@/src/features/chart-view/components/ChartViewPanel";-export {- AggregationSelect,- BreakdownSelect,- ChartTypePicker,- GranularitySelect,- MetricSelect,-} from "@/src/features/chart-view/components/ConfigControls";-export { ViewModeToggle } from "@/src/features/chart-view/components/ViewModeToggle";-export type { ChartWidgetInput } from "@/src/features/chart-view/lib/chartConfigToWidget";-export { useChartViewState } from "@/src/features/chart-view/lib/useChartViewState";diff --git a/web/src/features/chart-view/lib/buildChartQuery.ts b/web/src/features/chart-view/lib/buildChartQuery.tsindex 343646ba3c..671dc09802 100644--- a/web/src/features/chart-view/lib/buildChartQuery.ts+++ b/web/src/features/chart-view/lib/buildChartQuery.ts@@ -1,8 +1,6 @@import { type FilterState, type QueryType } from "@langfuse/shared";-import {- type DataPoint,- getWidgetMissingBucketValue,-} from "@/src/features/widgets";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";+import { getWidgetMissingBucketValue } from "@/src/features/widgets/utils";import { type ChartViewConfig } from "../types";import { getDimension, getMetric, isTimeSeriesChartType } from "../vocab";diff --git a/web/src/features/chart-view/lib/chartFilterCompatibility.ts b/web/src/features/chart-view/lib/chartFilterCompatibility.tsindex 74ce08808a..588f93e91e 100644--- a/web/src/features/chart-view/lib/chartFilterCompatibility.ts+++ b/web/src/features/chart-view/lib/chartFilterCompatibility.ts@@ -1,5 +1,5 @@import { type FilterCondition, type FilterState } from "@langfuse/shared";-import { resolveField } from "@/src/features/search-bar";+import { resolveField } from "@/src/features/search-bar/lib/fields";/*** Which of the events table's sidebar/search filters a chart can honour, and adiff --git a/web/src/features/column-visibility/index.ts b/web/src/features/column-visibility/index.tsdeleted file mode 100644index 9843e25b0b..0000000000--- a/web/src/features/column-visibility/index.ts+++ /dev/null@@ -1,5 +0,0 @@-// The column-visibility feature's public surface (RFC rule 8). Both hooks are-// default exports in their own files; the door names them, so consumers import-// them by name.-export { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";-export { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";diff --git a/web/src/features/command-k-menu/CommandMenu.tsx b/web/src/features/command-k-menu/CommandMenu.tsxindex baef94727b..e5bad61968 100644--- a/web/src/features/command-k-menu/CommandMenu.tsx+++ b/web/src/features/command-k-menu/CommandMenu.tsx@@ -31,23 +31,23 @@ import { keepPreviousData } from "@tanstack/react-query";import { Fragment, useEffect, memo, useState } from "react";import { useSession } from "next-auth/react";import { env } from "@/src/env.mjs";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useDebounce } from "@/src/hooks/useDebounce";import { useCommandMenu } from "@/src/features/command-k-menu/CommandMenuProvider";import { useOrganizationSettingsPages } from "@/src/features/organizations/OrganizationSettingsPage";-import { useAccountSettingsPages } from "@/src/features/account";-import { useQueryProjectOrOrganization } from "@/src/features/projects";+import { useAccountSettingsPages } from "@/src/features/account/AccountSettingsPage";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";import { useProjectSettingsPages } from "@/src/features/projects/ProjectSettingsPage";import { api } from "@/src/utils/api";import { type NavigationItem } from "@/src/components/layouts/utilities/routes";import useLocalStorage from "@/src/components/useLocalStorage";import { hasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { type ProjectScope } from "@langfuse/shared";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import {useInAppAiAgent,useIsInAppAgentLauncherVisible,-} from "@/src/features/in-app-agent";+} from "@/src/features/in-app-agent/components/InAppAiAgentProvider";type IdNavigationItem = {type: "trace_id" | "observation_id";diff --git a/web/src/features/comments/CommentDrawerController.clienttest.tsx b/web/src/features/comments/CommentDrawerController.clienttest.tsxindex 75c447ef3e..aedeb53eb0 100644--- a/web/src/features/comments/CommentDrawerController.clienttest.tsx+++ b/web/src/features/comments/CommentDrawerController.clienttest.tsx@@ -31,7 +31,9 @@ const { fetchComments, invalidateComments, router } = vi.hoisted(() => ({}));vi.mock("next/router", () => ({ useRouter: () => router }));-vi.mock("@/src/features/rbac", () => ({ useHasProjectAccess: () => true }));+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({+ useHasProjectAccess: () => true,+}));vi.mock("@/src/utils/api", () => ({api: {useUtils: () => ({diff --git a/web/src/features/comments/CommentDrawerController.tsx b/web/src/features/comments/CommentDrawerController.tsxindex a7fa017f17..ea829884fc 100644--- a/web/src/features/comments/CommentDrawerController.tsx+++ b/web/src/features/comments/CommentDrawerController.tsx@@ -1,7 +1,7 @@import { useRouter } from "next/router";import { useRef, useState, type ReactNode } from "react";import { type CommentObjectType } from "@langfuse/shared";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import {useTraceReviewPanelOptional,diff --git a/web/src/features/comments/CommentList.clienttest.tsx b/web/src/features/comments/CommentList.clienttest.tsxindex ad033a0c76..8a84295daa 100644--- a/web/src/features/comments/CommentList.clienttest.tsx+++ b/web/src/features/comments/CommentList.clienttest.tsx@@ -36,7 +36,7 @@ vi.mock("@/src/utils/api", () => ({},}));-vi.mock("@/src/features/rbac", () => ({+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({useHasProjectAccess: ({ scope }: { scope: string }) =>scope === "comments:read" ? accessState.hasReadAccess : true,}));diff --git a/web/src/features/comments/CommentList.tsx b/web/src/features/comments/CommentList.tsxindex 1897f6ae18..05ab08d14b 100644--- a/web/src/features/comments/CommentList.tsx+++ b/web/src/features/comments/CommentList.tsx@@ -1,7 +1,7 @@import { useRef, type ReactNode } from "react";import { Spinner } from "@/src/components/design-system/Spinner/Spinner";import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { cn } from "@/src/utils/tailwind";import { type CommentObjectType } from "@langfuse/shared";diff --git a/web/src/features/comments/components/CommentComposer.clienttest.tsx b/web/src/features/comments/components/CommentComposer.clienttest.tsxindex a6dc632cb9..a82c572976 100644--- a/web/src/features/comments/components/CommentComposer.clienttest.tsx+++ b/web/src/features/comments/components/CommentComposer.clienttest.tsx@@ -12,7 +12,9 @@ const mocks = vi.hoisted(() => ({mutate: vi.fn(),}));-vi.mock("@/src/features/rbac", () => ({ useHasProjectAccess: () => false }));+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({+ useHasProjectAccess: () => false,+}));vi.mock("@/src/utils/api", () => ({api: {comments: {diff --git a/web/src/features/comments/components/CommentComposer.tsx b/web/src/features/comments/components/CommentComposer.tsxindex 59d47fa3f8..83f07fa545 100644--- a/web/src/features/comments/components/CommentComposer.tsx+++ b/web/src/features/comments/components/CommentComposer.tsx@@ -17,7 +17,7 @@ import {PopoverAnchor,PopoverContent,} from "@/src/components/ui/popover";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { CommentEditor, type CommentEditorHandle } from "./CommentEditor";import { MentionAutocomplete } from "./MentionAutocomplete";diff --git a/web/src/features/comments/hooks/useCommentedPaths.ts b/web/src/features/comments/hooks/useCommentedPaths.tsindex ca940d99da..1d0f72e02c 100644--- a/web/src/features/comments/hooks/useCommentedPaths.ts+++ b/web/src/features/comments/hooks/useCommentedPaths.ts@@ -1,8 +1,8 @@import { useMemo } from "react";-import {- type CommentRange,- type CommentedPathsByField,-} from "@/src/features/traces";+import type {+ CommentRange,+ CommentedPathsByField,+} from "@/src/features/traces/components/AdvancedJsonViewer/utils/commentRanges";interface CommentWithPosition {content: string;diff --git a/web/src/features/comments/index.ts b/web/src/features/comments/index.tsdeleted file mode 100644index f85256ab3a..0000000000--- a/web/src/features/comments/index.ts+++ /dev/null@@ -1,14 +0,0 @@-// The comments feature's public client surface (RFC rule 8). Named-// re-exports only — the drawer and list other features already imported-// by file path.-//-// CommentCountIcon, MentionBadge, mentionParser, and the IOPreview-// inline-comment components stay deep: putting them here would load the-// drawer into SpanContent, MarkdownView, and IOPreviewJSON. Pages and-// commentsRouter stay off this door.-export {- CommentDrawerController,- getCommentDrawerInitialStateFromUrl,-} from "@/src/features/comments/CommentDrawerController";-export { CommentList } from "@/src/features/comments/CommentList";-export { useCommentedPaths } from "@/src/features/comments/hooks/useCommentedPaths";diff --git a/web/src/features/comments/server/index.ts b/web/src/features/comments/server/index.tsdeleted file mode 100644index 0074788d06..0000000000--- a/web/src/features/comments/server/index.ts+++ /dev/null@@ -1,7 +0,0 @@-// The comments feature's public server surface (RFC rules 8 and 10).-// commentsRouter stays a direct import from the tRPC root.-export {- createCommentForApi,- getCommentForApi,- listCommentsForApi,-} from "@/src/features/comments/server/publicCommentService";diff --git a/web/src/features/comments/server/publicCommentService.ts b/web/src/features/comments/server/publicCommentService.tsindex 6e43c224a8..0d6b39ddfa 100644--- a/web/src/features/comments/server/publicCommentService.ts+++ b/web/src/features/comments/server/publicCommentService.ts@@ -1,13 +1,13 @@import { v4 } from "uuid";import type { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { validateCommentReferenceObject } from "@/src/features/comments/validateCommentReferenceObject";-import {- type GetCommentV1Query,- type GetCommentsV1Query,- type PostCommentsV1Body,-} from "@/src/features/public-api/server";+import type {+ GetCommentV1Query,+ GetCommentsV1Query,+ PostCommentsV1Body,+} from "@/src/features/public-api/types/comments";import { InvalidRequestError, LangfuseNotFoundError } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";diff --git a/web/src/features/corrections/index.ts b/web/src/features/corrections/index.tsdeleted file mode 100644index 33542c3b09..0000000000--- a/web/src/features/corrections/index.ts+++ /dev/null@@ -1,8 +0,0 @@-// The corrections feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export {- CorrectionCacheProvider,- useCorrectionCache,- useCorrectionCacheOptional,-} from "@/src/features/corrections/contexts/CorrectionCacheProvider";-export { getMostRecentCorrection } from "@/src/features/corrections/utils/getMostRecentCorrection";diff --git a/web/src/features/customer-data-warning/index.ts b/web/src/features/customer-data-warning/index.tsdeleted file mode 100644index 8b416e3120..0000000000--- a/web/src/features/customer-data-warning/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { CustomerDataWarningBannerView } from "./CustomerDataWarningBannerView";-export { getCustomerDataWarning } from "./getCustomerDataWarning";diff --git a/web/src/features/dashboard/DashboardDetailPage.tsx b/web/src/features/dashboard/DashboardDetailPage.tsxindex fc8be5672f..718c9b208d 100644--- a/web/src/features/dashboard/DashboardDetailPage.tsx+++ b/web/src/features/dashboard/DashboardDetailPage.tsx@@ -1,12 +1,17 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */import { useRouter } from "next/router";import { api } from "@/src/utils/api";-import { useReadPath, type ResolvedReadPath } from "@/src/features/events";+import {+ useReadPath,+ type ResolvedReadPath,+} from "@/src/features/events/hooks/useReadPath";+import { useDashboardFilterOptions } from "@/src/hooks/useDashboardFilterOptions";import Page from "@/src/components/layouts/Page";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";import { TimeRangePicker } from "@/src/components/date-picker";-import { PopoverFilterBuilder, MultiSelect } from "@/src/features/filters";+import { PopoverFilterBuilder } from "@/src/features/filters/components/filter-builder";+import { MultiSelect } from "@/src/features/filters/components/MultiSelect";import { useEffect, useState, useMemo, useCallback, useRef } from "react";import {@@ -25,25 +30,29 @@ import {MoreVertical,PencilIcon,} from "@langfuse/icons";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import {SelectWidgetDialog,type WidgetItem,} from "@/src/features/widgets/components/SelectWidgetDialog";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { v4 as uuidv4 } from "uuid";import { useDebounce } from "@/src/hooks/useDebounce";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {type DashboardPlacement,+ DashboardGrid,+} from "@/src/features/widgets/components/DashboardGrid";+import {parsePastedWidget,toWidgetCreateFields,type PastedWidgetParseResult,type WidgetExportSource,- pushDownForInsertion,- useClipboardWidgetProbe,-} from "@/src/features/widgets";-import { DashboardGrid } from "@/src/features/widgets/components/DashboardGrid";+} from "@/src/features/widgets/utils/import-export-utils";+import { pushDownForInsertion } from "@/src/features/widgets/utils/grid-placement";+import { useClipboardWidgetProbe } from "@/src/features/widgets/hooks/useClipboardWidgetProbe";+import { ConnectedCloneDashboardDialogController } from "@/src/features/dashboard/components/ConnectedCloneDashboardDialogController";import { PageHeaderControlsPortal } from "@/src/components/layouts/page-header-controls-slot";import {@@ -59,7 +68,7 @@ import {DASHBOARD_AGGREGATION_OPTIONS,toAbsoluteTimeRange,} from "@/src/utils/date-range-utils";-import { useEntitlementLimit } from "@/src/features/entitlements";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";import { useEnvironmentFilterOptionsCache } from "@/src/hooks/use-environment-filter-options-cache";import {diff --git a/web/src/features/dashboard/DashboardsPage.tsx b/web/src/features/dashboard/DashboardsPage.tsxindex aa51729e5f..18b78e6dd0 100644--- a/web/src/features/dashboard/DashboardsPage.tsx+++ b/web/src/features/dashboard/DashboardsPage.tsx@@ -3,8 +3,11 @@ import Page from "@/src/components/layouts/Page";import { ConnectedDashboardTable } from "@/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable";import { ActionButton } from "@/src/components/ActionButton";import { PlusIcon } from "@langfuse/icons";-import { useHasProjectAccess } from "@/src/features/rbac";-import { getDashboardTabs, DASHBOARD_TABS } from "@/src/features/navigation";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import {+ getDashboardTabs,+ DASHBOARD_TABS,+} from "@/src/features/navigation/utils/dashboard-tabs";export default function DashboardsPage() {const router = useRouter();diff --git a/web/src/features/dashboard/NewDashboardPage.tsx b/web/src/features/dashboard/NewDashboardPage.tsxindex ead02f9c2b..e1a2c0514a 100644--- a/web/src/features/dashboard/NewDashboardPage.tsx+++ b/web/src/features/dashboard/NewDashboardPage.tsx@@ -6,8 +6,9 @@ import { Button } from "@/src/components/ui/button";import { Input } from "@/src/components/ui/input";import { Textarea } from "@/src/components/ui/textarea";import { Label } from "@/src/components/ui/label";-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";export default function NewDashboardPage() {diff --git a/web/src/features/dashboard/ProjectHomePage.tsx b/web/src/features/dashboard/ProjectHomePage.tsxindex 710c19b251..b67c6488ee 100644--- a/web/src/features/dashboard/ProjectHomePage.tsx+++ b/web/src/features/dashboard/ProjectHomePage.tsx@@ -4,11 +4,9 @@ import { api } from "@/src/utils/api";import { TimeRangePicker } from "@/src/components/date-picker";import { PageHeaderControlsPortal } from "@/src/components/layouts/page-header-controls-slot";import { useDashboardFilterOptions } from "@/src/hooks/useDashboardFilterOptions";-import {- PopoverFilterBuilder,- useQueryFilterState,- MultiSelect,-} from "@/src/features/filters";+import { PopoverFilterBuilder } from "@/src/features/filters/components/filter-builder";+import { useQueryFilterState } from "@/src/features/filters/hooks/useFilterState";+import { MultiSelect } from "@/src/features/filters/components/MultiSelect";import {LANGFUSE_HOME_DASHBOARD_DEFINITION,@@ -25,14 +23,18 @@ import {} from "@/src/utils/date-range-utils";import { useDashboardDateRange } from "@/src/hooks/useDashboardDateRange";import { useDebounce } from "@/src/hooks/useDebounce";-import { useEntitlementLimit } from "@/src/features/entitlements";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";import Page from "@/src/components/layouts/Page";import {convertSelectedEnvironmentsToFilter,useEnvironmentFilter,} from "@/src/hooks/useEnvironmentFilter";-import { useReadPath, type ResolvedReadPath } from "@/src/features/events";+import {+ useReadPath,+ type ResolvedReadPath,+} from "@/src/features/events/hooks/useReadPath";+import { type ViewVersion } from "@langfuse/shared/query";import { useEnvironmentFilterOptionsCache } from "@/src/hooks/use-environment-filter-options-cache";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";@@ -43,15 +45,15 @@ import {} from "@/src/features/dashboard/hooks/DashboardQuerySchedulerProvider";import Link from "next/link";import { LockIcon, PencilIcon } from "@langfuse/icons";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Button } from "@/src/components/ui/button";import { DashboardGrid } from "@/src/features/widgets/components/DashboardGrid";import { HomeDashboardSelect } from "@/src/features/dashboard/components/HomeDashboardSelect";-import { useQueryProjectOrOrganization } from "@/src/features/projects";-import { setupTracingRoute } from "@/src/features/setup";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { setupTracingRoute } from "@/src/features/setup/setupRoutes";// Controller: no widget query may fire before the session resolves the v3/v4// read path — an unresolved session used to read as v3, fire a full wave ofdiff --git a/web/src/features/dashboard/components/ChartScores.tsx b/web/src/features/dashboard/components/ChartScores.tsxindex 76202b2326..a95e5b4549 100644--- a/web/src/features/dashboard/components/ChartScores.tsx+++ b/web/src/features/dashboard/components/ChartScores.tsx@@ -11,12 +11,12 @@ import {type DashboardDateRangeAggregationOption,dashboardDateRangeAggregationSettings,} from "@/src/utils/date-range-utils";-import { getScoreDataTypeIcon } from "@/src/features/scores";+import { getScoreDataTypeIcon } from "@/src/features/scores/lib/scoreColumns";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";import { type QueryType, type ViewVersion } from "@langfuse/shared/query";import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import { type DatabaseRow } from "@/src/server/api/services/sqlInterface";-import { Chart } from "@/src/features/widgets";+import { Chart } from "@/src/features/widgets/chart-library/Chart";import { timeSeriesToDataPoints } from "@/src/features/dashboard/lib/chart-data-adapters";import { useScheduledDashboardExecuteQuery } from "@/src/features/dashboard/hooks/DashboardQuerySchedulerProvider";diff --git a/web/src/features/dashboard/components/ConnectedCloneDashboardDialogController.tsx b/web/src/features/dashboard/components/ConnectedCloneDashboardDialogController.tsxindex 1264ac1f70..6612040b40 100644--- a/web/src/features/dashboard/components/ConnectedCloneDashboardDialogController.tsx+++ b/web/src/features/dashboard/components/ConnectedCloneDashboardDialogController.tsx@@ -3,9 +3,10 @@ import { useRouter } from "next/router";import { api } from "@/src/utils/api";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { CloneDashboardDialog } from "./CloneDashboardDialog";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import type { DashboardPlacement } from "@/src/features/widgets";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import type { DashboardPlacement } from "@/src/features/widgets/components/DashboardGrid";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";/**diff --git a/web/src/features/dashboard/components/DashboardLineTimeSeriesChart.tsx b/web/src/features/dashboard/components/DashboardLineTimeSeriesChart.tsxindex 0e3b49a264..98bfea345e 100644--- a/web/src/features/dashboard/components/DashboardLineTimeSeriesChart.tsx+++ b/web/src/features/dashboard/components/DashboardLineTimeSeriesChart.tsx@@ -1,9 +1,9 @@import React, { useMemo } from "react";-import {- Chart,- type LegendSummaryMode,- type MissingBucketValue,-} from "@/src/features/widgets";+import { Chart } from "@/src/features/widgets/chart-library/Chart";+import type {+ LegendSummaryMode,+ MissingBucketValue,+} from "@/src/features/widgets/chart-library/chart-props";import { timeSeriesToDataPoints } from "@/src/features/dashboard/lib/chart-data-adapters";import { type TimeSeriesChartDataPoint } from "@/src/features/dashboard/components/hooks";diff --git a/web/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable.tsx b/web/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable.tsxindex b88c79b166..79409631a0 100644--- a/web/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable.tsx+++ b/web/src/features/dashboard/components/DashboardTable/ConnectedDashboardTable.tsx@@ -1,14 +1,15 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useEffect, useMemo, useState } from "react";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { NumberParam, useQueryParams, withDefault } from "use-query-params";import { api } from "@/src/utils/api";import { safeExtract } from "@/src/utils/map-utils";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { EditDialogDashboardContent } from "@/src/features/dashboard/components/EditDialogDashboardContent";import { ConnectedCloneDashboardDialogController } from "@/src/features/dashboard/components/ConnectedCloneDashboardDialogController";import { useRouter } from "next/router";diff --git a/web/src/features/dashboard/components/EditDialogDashboardContent.tsx b/web/src/features/dashboard/components/EditDialogDashboardContent.tsxindex 9c185b804e..350fd64ac1 100644--- a/web/src/features/dashboard/components/EditDialogDashboardContent.tsx+++ b/web/src/features/dashboard/components/EditDialogDashboardContent.tsx@@ -11,7 +11,7 @@ import { Button } from "@/src/components/ui/button";import { Input } from "@/src/components/ui/input";import { Label } from "@/src/components/ui/label";import { Textarea } from "@/src/components/ui/textarea";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";interface EditDialogDashboardContentProps {diff --git a/web/src/features/dashboard/components/HomeDashboardSelect.tsx b/web/src/features/dashboard/components/HomeDashboardSelect.tsxindex 4c3f2e85b4..129751c1da 100644--- a/web/src/features/dashboard/components/HomeDashboardSelect.tsx+++ b/web/src/features/dashboard/components/HomeDashboardSelect.tsx@@ -4,7 +4,7 @@ import { api } from "@/src/utils/api";import { Combobox } from "@/src/components/ui/Combobox";import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/LangfuseIcon";import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";/*** Home's dashboard picker: selecting immediately shows ("peeks") the chosendiff --git a/web/src/features/dashboard/components/LatencyTables.tsx b/web/src/features/dashboard/components/LatencyTables.tsxindex 7b8252beb1..e21a9620fd 100644--- a/web/src/features/dashboard/components/LatencyTables.tsx+++ b/web/src/features/dashboard/components/LatencyTables.tsx@@ -6,10 +6,11 @@ import {ObservationType,type FilterState,getGenerationLikeTypes,+ truncate,} from "@langfuse/shared";import { formatIntervalSeconds } from "@/src/utils/dates";-import { truncate } from "@/src/utils/string";+import { cn } from "@/src/utils/tailwind";import { Popup } from "@/src/components/layouts/doc-popup";import { type QueryType, type ViewVersion } from "@langfuse/shared/query";diff --git a/web/src/features/dashboard/components/ModelCostTable.tsx b/web/src/features/dashboard/components/ModelCostTable.tsxindex adc0e4dd0f..e88b80bad0 100644--- a/web/src/features/dashboard/components/ModelCostTable.tsx+++ b/web/src/features/dashboard/components/ModelCostTable.tsx@@ -4,10 +4,14 @@ import { RightAlignedCell } from "@/src/features/dashboard/components/RightAlignimport { LeftAlignedCell } from "@/src/features/dashboard/components/LeftAlignedCell";import { DashboardCard } from "@/src/features/dashboard/components/cards/DashboardCard";import { DashboardTable } from "@/src/features/dashboard/components/cards/DashboardTable";-import { type FilterState, getGenerationLikeTypes } from "@langfuse/shared";+import {+ type FilterState,+ getGenerationLikeTypes,+ truncate,+} from "@langfuse/shared";import { compactNumberFormatter, costFormatter } from "@/src/utils/numbers";import { TotalMetric } from "./TotalMetric";-import { truncate } from "@/src/utils/string";+import { type QueryType, type ViewVersion } from "@langfuse/shared/query";import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import { useScheduledDashboardExecuteQuery } from "@/src/features/dashboard/hooks/DashboardQuerySchedulerProvider";diff --git a/web/src/features/dashboard/components/ScoresTable.tsx b/web/src/features/dashboard/components/ScoresTable.tsxindex 5ae795540f..e85e573e7c 100644--- a/web/src/features/dashboard/components/ScoresTable.tsx+++ b/web/src/features/dashboard/components/ScoresTable.tsx@@ -14,12 +14,12 @@ import { LeftAlignedCell } from "@/src/features/dashboard/components/LeftAlignedimport { cn } from "@/src/utils/tailwind";import { TotalMetric } from "./TotalMetric";import { createTracesTimeFilter } from "@/src/features/dashboard/lib/dashboard-utils";+import { getScoreDataTypeIcon } from "@/src/features/scores/lib/scoreColumns";import {- getScoreDataTypeIcon,isBooleanDataType,isCategoricalDataType,isNumericDataType,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/helpers";import { type DatabaseRow } from "@/src/server/api/services/sqlInterface";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";diff --git a/web/src/features/dashboard/components/TabComponent.tsx b/web/src/features/dashboard/components/TabComponent.tsxindex 1d4cd0fc17..d541cd0f77 100644--- a/web/src/features/dashboard/components/TabComponent.tsx+++ b/web/src/features/dashboard/components/TabComponent.tsx@@ -1,5 +1,5 @@import { Tabs } from "@/src/components/design-system/Tabs/Tabs";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type ChangeEvent, type ReactNode, useState } from "react";export type TabComponentProps = {diff --git a/web/src/features/dashboard/components/TracesBarListChart.tsx b/web/src/features/dashboard/components/TracesBarListChart.tsxindex 15f661e186..a9a1804168 100644--- a/web/src/features/dashboard/components/TracesBarListChart.tsx+++ b/web/src/features/dashboard/components/TracesBarListChart.tsx@@ -5,7 +5,7 @@ import { TotalMetric } from "@/src/features/dashboard/components/TotalMetric";import { compactNumberFormatter } from "@/src/utils/numbers";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";import { type QueryType, type ViewVersion } from "@langfuse/shared/query";-import { formatMetric } from "@/src/features/widgets";+import { formatMetric } from "@/src/features/widgets/chart-library/utils";import { BarListChartArea } from "@/src/features/dashboard/components/cards/BarListChartArea";import { traceViewQuery } from "@/src/features/dashboard/lib/dashboard-utils";import { useScheduledDashboardExecuteQuery } from "@/src/features/dashboard/hooks/DashboardQuerySchedulerProvider";diff --git a/web/src/features/dashboard/components/cards/BarListChartArea.tsx b/web/src/features/dashboard/components/cards/BarListChartArea.tsxindex 42b06b0a75..de58dfda49 100644--- a/web/src/features/dashboard/components/cards/BarListChartArea.tsx+++ b/web/src/features/dashboard/components/cards/BarListChartArea.tsx@@ -1,4 +1,5 @@-import { Chart, type MetricFormatterFunction } from "@/src/features/widgets";+import { Chart } from "@/src/features/widgets/chart-library/Chart";+import type { MetricFormatterFunction } from "@/src/features/widgets/chart-library/chart-props";import { barListToDataPoints } from "@/src/features/dashboard/lib/chart-data-adapters";export type BarListDataPoint = {diff --git a/web/src/features/dashboard/components/hooks.ts b/web/src/features/dashboard/components/hooks.tsindex 7bd9aec902..3f8680689e 100644--- a/web/src/features/dashboard/components/hooks.ts+++ b/web/src/features/dashboard/components/hooks.ts@@ -1,6 +1,6 @@/* eslint-disable @typescript-eslint/no-use-before-define */import { type FilterState, getGenerationLikeTypes } from "@langfuse/shared";-import type { MissingBucketValue } from "@/src/features/widgets";+import type { MissingBucketValue } from "@/src/features/widgets/chart-library/chart-props";export type TimeSeriesChartDataPoint = {ts: number;diff --git a/web/src/features/dashboard/components/score-analytics/CategoricalScoreChart.tsx b/web/src/features/dashboard/components/score-analytics/CategoricalScoreChart.tsxindex 6a2e5c55df..785cdc4dd6 100644--- a/web/src/features/dashboard/components/score-analytics/CategoricalScoreChart.tsx+++ b/web/src/features/dashboard/components/score-analytics/CategoricalScoreChart.tsx@@ -5,14 +5,12 @@ import {dashboardDateRangeAggregationSettings,} from "@/src/utils/date-range-utils";import React, { useMemo } from "react";-import {- DashboardCategoricalScoreAdapter,- type ScoreData,-} from "@/src/features/scores";+import { DashboardCategoricalScoreAdapter } from "@/src/features/scores/adapters/index";+import type { ScoreData } from "@/src/features/scores/types";import { type QueryType, type ViewVersion } from "@langfuse/shared/query";import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import { type DatabaseRow } from "@/src/server/api/services/sqlInterface";-import { Chart } from "@/src/features/widgets";+import { Chart } from "@/src/features/widgets/chart-library/Chart";import { scoreChartDataToDataPoints } from "@/src/features/dashboard/lib/chart-data-adapters";import { isEmptyChart } from "@/src/features/dashboard/lib/score-analytics-utils";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";diff --git a/web/src/features/dashboard/components/score-analytics/NumericScoreHistogram.tsx b/web/src/features/dashboard/components/score-analytics/NumericScoreHistogram.tsxindex 7c8c5c90f7..4efc03a962 100644--- a/web/src/features/dashboard/components/score-analytics/NumericScoreHistogram.tsx+++ b/web/src/features/dashboard/components/score-analytics/NumericScoreHistogram.tsx@@ -8,7 +8,7 @@ import { type ViewVersion } from "@langfuse/shared/query";import { createTracesTimeFilter } from "@/src/features/dashboard/lib/dashboard-utils";import React from "react";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";-import { Chart } from "@/src/features/widgets";+import { Chart } from "@/src/features/widgets/chart-library/Chart";import { scoreHistogramToDataPoints } from "@/src/features/dashboard/lib/chart-data-adapters";export function NumericScoreHistogram(props: {diff --git a/web/src/features/dashboard/components/score-analytics/ScoreAnalytics.tsx b/web/src/features/dashboard/components/score-analytics/ScoreAnalytics.tsxindex e76c9f4731..743b631b7b 100644--- a/web/src/features/dashboard/components/score-analytics/ScoreAnalytics.tsx+++ b/web/src/features/dashboard/components/score-analytics/ScoreAnalytics.tsx@@ -7,10 +7,12 @@ import { type DashboardDateRangeAggregationOption } from "@/src/utils/date-rangeimport {convertScoreColumnsToAnalyticsData,getScoreDataTypeIcon,+} from "@/src/features/scores/lib/scoreColumns";+import {isBooleanDataType,isCategoricalDataType,isNumericDataType,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/helpers";import React, { useMemo } from "react";import { Separator } from "@/src/components/ui/separator";import { NumericScoreTimeSeriesChart } from "@/src/features/dashboard/components/score-analytics/NumericScoreTimeSeriesChart";diff --git a/web/src/features/dashboard/hooks/useDashboardDefinitionDraft.ts b/web/src/features/dashboard/hooks/useDashboardDefinitionDraft.tsindex a520f4c485..c235adbd5e 100644--- a/web/src/features/dashboard/hooks/useDashboardDefinitionDraft.ts+++ b/web/src/features/dashboard/hooks/useDashboardDefinitionDraft.ts@@ -1,6 +1,6 @@import { useCallback, useRef, useState } from "react";-import type { DashboardPlacement } from "@/src/features/widgets";+import type { DashboardPlacement } from "@/src/features/widgets/components/DashboardGrid";export type DashboardDefinition = {widgets: DashboardPlacement[];diff --git a/web/src/features/dashboard/index.ts b/web/src/features/dashboard/index.tsdeleted file mode 100644index 364a0cca16..0000000000--- a/web/src/features/dashboard/index.ts+++ /dev/null@@ -1,39 +0,0 @@-// The dashboard feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported from this-// feature's client modules.-//-// SelectDashboardDialog, home-preset-registry, and-// useDashboardQueryScheduler stay off this door: mapping helpers are-// imported by widgets/utils and scores adapters, and putting the dialog or-// home-chart registry here would load that UI into every mapping consumer.-// dashboardUiTableToViewMapping stays on this door for client callers-// and on server/index.ts for server callers (rule 10). Pages and-// dashboardRouter stay off this door.-export {- buildTableFilterHref,- buildViewAsTableHint,-} from "@/src/features/dashboard/lib/buildTableFilterHref";-export {- compareViewChartDataToDataPoints,- getCompareViewChartUnit,-} from "@/src/features/dashboard/lib/chart-data-adapters";-export {- displayNameForFilterColumn,- getWidgetImportFilterConfig,- mapLegacyUiTableFilterToView,- mapViewFilterToUiTableFilter,- mapWidgetUiTableFilterToView,- normalizeStoredWidgetFiltersForEditor,- partitionStoredUiTableFiltersToView,- partitionWidgetUiTableFiltersToView,-} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";-export {- isEmptyChart,- RESOURCE_METRICS,- transformAggregatedRunMetricsToChartData,- transformCategoricalScoresToChartData,- uniqueAndSort,-} from "@/src/features/dashboard/lib/score-analytics-utils";-// buildPresetExport stays a deep import: dashboard-import-export loads-// @/src/features/widgets, so putting it on this door would close a-// widgets/dashboard cycle.diff --git a/web/src/features/dashboard/lib/chart-data-adapters.ts b/web/src/features/dashboard/lib/chart-data-adapters.tsindex a034733236..89e7681a07 100644--- a/web/src/features/dashboard/lib/chart-data-adapters.ts+++ b/web/src/features/dashboard/lib/chart-data-adapters.ts@@ -2,9 +2,9 @@* Adapters that transform data prepared for tremor-v4-chart to the recharts chart library data format.* This can be removed once we have converted all data API calls to the DataPoint format that recharts expects.*/-import type { DataPoint } from "@/src/features/widgets";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";import type { TimeSeriesChartDataPoint } from "@/src/features/dashboard/components/hooks";-import type { ChartBin } from "@/src/features/scores";+import type { ChartBin } from "@/src/features/scores/types";/** Histogram bin shape: binLabel plus numeric fields (e.g. count). Compatible with createHistogramData return type. */type HistogramBinLike = { binLabel: string; [key: string]: string | number };diff --git a/web/src/features/dashboard/lib/score-analytics-utils.ts b/web/src/features/dashboard/lib/score-analytics-utils.tsindex 3099537bb4..4c24fef928 100644--- a/web/src/features/dashboard/lib/score-analytics-utils.ts+++ b/web/src/features/dashboard/lib/score-analytics-utils.ts@@ -1,6 +1,6 @@import { type DashboardDateRangeAggregationOption } from "@/src/utils/date-range-utils";import { type DatabaseRow } from "@/src/server/api/services/sqlInterface";-import type { CategoryCounts, ChartBin } from "@/src/features/scores";+import type { CategoryCounts, ChartBin } from "@/src/features/scores/types";import { type RouterOutputs } from "@/src/utils/api";export const RESOURCE_METRICS = [diff --git a/web/src/features/dashboard/server/dashboard-router.ts b/web/src/features/dashboard/server/dashboard-router.tsindex 6930b03190..cb057bebef 100644--- a/web/src/features/dashboard/server/dashboard-router.ts+++ b/web/src/features/dashboard/server/dashboard-router.ts@@ -39,7 +39,7 @@ import {LANGFUSE_HOME_DASHBOARD_ID,type FilterState,} from "@langfuse/shared";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";// Define the dashboard list input schemaconst ListDashboardsInput = z.object({diff --git a/web/src/features/dashboard/server/index.ts b/web/src/features/dashboard/server/index.tsdeleted file mode 100644index 9e04e0b184..0000000000--- a/web/src/features/dashboard/server/index.ts+++ /dev/null@@ -1,16 +0,0 @@-// The dashboard feature's server surface (RFC rule 9, amended): the-// public dashboard services MCP tools already imported by file path.-export {- getWidgetImportFilterConfig,- partitionStoredUiTableFiltersToView,-} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";-export {- addPublicDashboardPlacement,- createPublicDashboard,- deletePublicDashboard,- deletePublicDashboardPlacement,- getPublicDashboard,- listPublicDashboards,- updatePublicDashboard,- updatePublicDashboardPlacement,-} from "@/src/features/dashboard/server/public-dashboard-service";diff --git a/web/src/features/dashboard/server/public-dashboard-service.ts b/web/src/features/dashboard/server/public-dashboard-service.tsindex a614911eac..5d19044ae5 100644--- a/web/src/features/dashboard/server/public-dashboard-service.ts+++ b/web/src/features/dashboard/server/public-dashboard-service.ts@@ -8,7 +8,7 @@ import {LangfuseConflictError,LangfuseNotFoundError,} from "@langfuse/shared";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {DashboardSchema,type DashboardPlacementSchema,@@ -16,7 +16,8 @@ import {type PatchUnstableDashboardBody,type PostDashboardPlacementBody,type PostUnstableDashboardBody,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/unstable-dashboards";+import type { z } from "zod";import { randomUUID } from "crypto";diff --git a/web/src/features/dashboard/utils/dashboard-import-export.clienttest.ts b/web/src/features/dashboard/utils/dashboard-import-export.clienttest.tsindex 2c1ae8e2a5..b71eec05db 100644--- a/web/src/features/dashboard/utils/dashboard-import-export.clienttest.ts+++ b/web/src/features/dashboard/utils/dashboard-import-export.clienttest.ts@@ -13,7 +13,7 @@ import {import {buildWidgetExport,type WidgetExportSource,-} from "@/src/features/widgets";+} from "@/src/features/widgets/utils/import-export-utils";const baseWidget: WidgetExportSource = {name: "Trace count",diff --git a/web/src/features/dashboard/utils/dashboard-import-export.ts b/web/src/features/dashboard/utils/dashboard-import-export.tsindex 2f7ae57b26..d322120663 100644--- a/web/src/features/dashboard/utils/dashboard-import-export.ts+++ b/web/src/features/dashboard/utils/dashboard-import-export.ts@@ -10,7 +10,7 @@ import {parsePastedWidget,type WidgetExportSource,type WidgetImport,-} from "@/src/features/widgets";+} from "@/src/features/widgets/utils/import-export-utils";/*** Dashboard JSON file-format version. `$langfuseDashboard: true` marks a JSONdiff --git a/web/src/features/datasets/DatasetCompareChartsPage.tsx b/web/src/features/datasets/DatasetCompareChartsPage.tsxindex c8a30531d6..fca2e93d75 100644--- a/web/src/features/datasets/DatasetCompareChartsPage.tsx+++ b/web/src/features/datasets/DatasetCompareChartsPage.tsx@@ -1,10 +1,8 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */import { Button } from "@/src/components/ui/button";-import {- MultiSelectKeyValues,- CompareViewAdapter,- getScoreDataTypeIcon,-} from "@/src/features/scores";+import { MultiSelectKeyValues } from "@/src/features/scores/components/MultiSelectKeyValues";+import { CompareViewAdapter } from "@/src/features/scores/adapters/index";+import { getScoreDataTypeIcon } from "@/src/features/scores/lib/scoreColumns";import { FlaskConical, List } from "@langfuse/icons";import { useRouter } from "next/router";import { useEffect, useState } from "react";@@ -14,21 +12,21 @@ import {DialogContent,DialogTrigger,} from "@/src/components/ui/dialog";-import {- CreateExperimentsForm,- useExperimentAccess,- toExperimentsResultsUrl,-} from "@/src/features/experiments";-import { useHasProjectAccess } from "@/src/features/rbac";+import { CreateExperimentsForm } from "@/src/features/experiments/components/CreateExperimentsForm";+import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";+import { toExperimentsResultsUrl } from "@/src/features/experiments/utils/experimentUrlTranslation";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { DatasetAnalytics } from "@/src/features/datasets/components/DatasetAnalytics";import {RESOURCE_METRICS,isEmptyChart,+} from "@/src/features/dashboard/lib/score-analytics-utils";+import {compareViewChartDataToDataPoints,getCompareViewChartUnit,-} from "@/src/features/dashboard";-import { Chart } from "@/src/features/widgets";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+} from "@/src/features/dashboard/lib/chart-data-adapters";+import { Chart } from "@/src/features/widgets/chart-library/Chart";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import Page from "@/src/components/layouts/Page";import { SubHeaderLabel } from "@/src/components/layouts/header";import {@@ -44,7 +42,7 @@ import { Skeleton } from "@/src/components/ui/skeleton";import {DATASET_RUN_COMPARE_TABS,getDatasetRunCompareTabs,-} from "@/src/features/navigation";+} from "@/src/features/navigation/utils/dataset-run-compare-tabs";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";function DatasetCompareChartsLegacy() {diff --git a/web/src/features/datasets/DatasetComparePage.tsx b/web/src/features/datasets/DatasetComparePage.tsxindex fa2422efdd..fc9bf8dbc6 100644--- a/web/src/features/datasets/DatasetComparePage.tsx+++ b/web/src/features/datasets/DatasetComparePage.tsx@@ -1,7 +1,7 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */import { Button } from "@/src/components/ui/button";import { DatasetCompareRunsTable } from "@/src/features/datasets/components/DatasetCompareRunsTable";-import { MultiSelectKeyValues } from "@/src/features/scores";+import { MultiSelectKeyValues } from "@/src/features/scores/components/MultiSelectKeyValues";import { FlaskConical, List } from "@langfuse/icons";import { useRouter } from "next/router";import { useEffect, useState } from "react";@@ -10,18 +10,16 @@ import {DialogContent,DialogTrigger,} from "@/src/components/ui/dialog";-import {- CreateExperimentsForm,- useExperimentAccess,- toExperimentsResultsUrl,-} from "@/src/features/experiments";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { CreateExperimentsForm } from "@/src/features/experiments/components/CreateExperimentsForm";+import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";+import { toExperimentsResultsUrl } from "@/src/features/experiments/utils/experimentUrlTranslation";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import Page from "@/src/components/layouts/Page";import {DATASET_RUN_COMPARE_TABS,getDatasetRunCompareTabs,-} from "@/src/features/navigation";+} from "@/src/features/navigation/utils/dataset-run-compare-tabs";import { useDatasetRunsCompare } from "@/src/features/datasets/hooks/useDatasetRunsCompare";import {ActiveCellProvider,diff --git a/web/src/features/datasets/DatasetExperimentsPage.tsx b/web/src/features/datasets/DatasetExperimentsPage.tsxindex 8a87d42b51..4bc4b0b6f0 100644--- a/web/src/features/datasets/DatasetExperimentsPage.tsx+++ b/web/src/features/datasets/DatasetExperimentsPage.tsx@@ -1,10 +1,10 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */import { DatasetRunsTable } from "@/src/features/datasets/components/DatasetRunsTable";import { api } from "@/src/utils/api";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import { useState, useCallback } from "react";import { FlaskConical, MoreVertical } from "@langfuse/icons";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {Dialog,DialogContent,@@ -13,19 +13,20 @@ import {DialogTrigger,} from "@/src/components/ui/dialog";import { Button } from "@/src/components/ui/button";-import {- CreateExperimentsForm,- useEvaluatorDefaults,- useExperimentEvaluatorData,- useExperimentAccess,- singleRunToExperimentsUrl,-} from "@/src/features/experiments";-import { showSuccessToast } from "@/src/features/notifications";+import { CreateExperimentsForm } from "@/src/features/experiments/components/CreateExperimentsForm";+import { useEvaluatorDefaults } from "@/src/features/experiments/hooks/useEvaluatorDefaults";+import { useExperimentEvaluatorData } from "@/src/features/experiments/hooks/useExperimentEvaluatorData";+import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";+import { singleRunToExperimentsUrl } from "@/src/features/experiments/utils/experimentUrlTranslation";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { DatasetAnalytics } from "@/src/features/datasets/components/DatasetAnalytics";-import { RESOURCE_METRICS } from "@/src/features/dashboard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { RESOURCE_METRICS } from "@/src/features/dashboard/lib/score-analytics-utils";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import Page from "@/src/components/layouts/Page";-import { getDatasetTabs, DATASET_TABS } from "@/src/features/navigation";+import {+ getDatasetTabs,+ DATASET_TABS,+} from "@/src/features/navigation/utils/dataset-tabs";import { TemplateSelector } from "@/src/features/evals/components/TemplateSelector";import {EvaluatorForm,@@ -33,7 +34,7 @@ import {} from "@/src/features/evals/components/EvaluatorForm";import useLocalStorage from "@/src/components/useLocalStorage";import { getDatasetBreadcrumb } from "@/src/features/datasets/utils/getDatasetBreadcrumb";-import { ExperimentsTable } from "@/src/features/experiments/components/table";+import { default as ExperimentsTable } from "@/src/features/experiments/components/table/ExperimentsTable";import { Skeleton } from "@/src/components/ui/skeleton";import { RouteParamsPendingFallback } from "@/src/components/RouteParamsPendingFallback/RouteParamsPendingFallback";import { useReadyRouteParams } from "@/src/hooks/useReadyRouteParams";diff --git a/web/src/features/datasets/DatasetItemPage.tsx b/web/src/features/datasets/DatasetItemPage.tsxindex 37b13a1ea8..991fa6a1c3 100644--- a/web/src/features/datasets/DatasetItemPage.tsx+++ b/web/src/features/datasets/DatasetItemPage.tsx@@ -1,4 +1,4 @@-import { DATASET_ITEM_TABS } from "@/src/features/navigation";+import { DATASET_ITEM_TABS } from "@/src/features/navigation/utils/dataset-item-tabs";import { DatasetItemDetailPage } from "@/src/features/datasets/components/DatasetItemDetailPage";import { DatasetItemViewModeContent } from "@/src/features/datasets/components/DatasetItemViewModeContent";import { DatasetItemVersionedContent } from "@/src/features/datasets/components/DatasetItemVersionedContent";diff --git a/web/src/features/datasets/DatasetItemRunsPage.tsx b/web/src/features/datasets/DatasetItemRunsPage.tsxindex ce5f0c0465..a1ef35f4d7 100644--- a/web/src/features/datasets/DatasetItemRunsPage.tsx+++ b/web/src/features/datasets/DatasetItemRunsPage.tsx@@ -1,9 +1,9 @@import { useRouter } from "next/router";import { useEffect } from "react";import { DatasetRunItemsByItemTable } from "@/src/features/datasets/components/DatasetRunItemsByItemTable";-import { DATASET_ITEM_TABS } from "@/src/features/navigation";+import { DATASET_ITEM_TABS } from "@/src/features/navigation/utils/dataset-item-tabs";import { DatasetItemDetailPage } from "@/src/features/datasets/components/DatasetItemDetailPage";-import { useExperimentAccess } from "@/src/features/experiments";+import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";import { RouteParamsPendingFallback } from "@/src/components/RouteParamsPendingFallback/RouteParamsPendingFallback";import { useReadyRouteParams } from "@/src/hooks/useReadyRouteParams";diff --git a/web/src/features/datasets/DatasetItemsPage.tsx b/web/src/features/datasets/DatasetItemsPage.tsxindex 38d4951cae..9a15f176ef 100644--- a/web/src/features/datasets/DatasetItemsPage.tsx+++ b/web/src/features/datasets/DatasetItemsPage.tsx@@ -1,7 +1,10 @@import { api } from "@/src/utils/api";-import { getDatasetTabs, DATASET_TABS } from "@/src/features/navigation";+import {+ getDatasetTabs,+ DATASET_TABS,+} from "@/src/features/navigation/utils/dataset-tabs";import { DatasetItemsTable } from "@/src/features/datasets/components/DatasetItemsTable";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import { NewDatasetItemButton } from "@/src/features/datasets/components/NewDatasetItemButton";import { UploadDatasetCsvButton } from "@/src/features/datasets/components/UploadDatasetCsvButton";import { Button } from "@/src/components/ui/button";diff --git a/web/src/features/datasets/DatasetRunPage.tsx b/web/src/features/datasets/DatasetRunPage.tsxindex 76931e322b..305d60c2ed 100644--- a/web/src/features/datasets/DatasetRunPage.tsx+++ b/web/src/features/datasets/DatasetRunPage.tsx@@ -2,7 +2,7 @@ import { Button } from "@/src/components/ui/button";import { JSONView } from "@/src/components/ui/CodeJsonViewer";import { DatasetRunItemsByRunTable } from "@/src/features/datasets/components/DatasetRunItemsByRunTable";import { DeleteDatasetRunDialogController } from "@/src/features/datasets/components/DeleteDatasetRunDialogController";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import { api } from "@/src/utils/api";import { Columns3, MoreVertical, Trash } from "@langfuse/icons";import Link from "next/link";@@ -18,10 +18,8 @@ import {} from "@/src/components/ui/side-panel";import { Skeleton } from "@/src/components/ui/skeleton";import { getDatasetBreadcrumb } from "@/src/features/datasets/utils/getDatasetBreadcrumb";-import {- useExperimentAccess,- singleRunToExperimentsUrl,-} from "@/src/features/experiments";+import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";+import { singleRunToExperimentsUrl } from "@/src/features/experiments/utils/experimentUrlTranslation";import { buildLocalIsoDatePresentation } from "@/src/utils/dates";function DatasetRunLegacy() {diff --git a/web/src/features/datasets/components/AnnotationPanel.clienttest.tsx b/web/src/features/datasets/components/AnnotationPanel.clienttest.tsxindex 784165f1b3..c79100e76d 100644--- a/web/src/features/datasets/components/AnnotationPanel.clienttest.tsx+++ b/web/src/features/datasets/components/AnnotationPanel.clienttest.tsx@@ -18,7 +18,12 @@ vi.mock("@/src/components/ui/resizable", () => ({ResizablePanel: ({ children }: { children: ReactNode }) => children,ResizableHandle: () => <hr />,}));-vi.mock("@/src/features/scores", () => ({+vi.mock("@/src/features/scores/components/AnnotationForm", () => ({+ AnnotationForm: ({ actionButtons }: { actionButtons: ReactNode }) =>+ actionButtons,+ decomposeAggregateScoreKey: () => ({ source: "ANNOTATION" }),+}));+vi.mock("@/src/features/scores/lib/aggregateScores", () => ({AnnotationForm: ({ actionButtons }: { actionButtons: ReactNode }) =>actionButtons,decomposeAggregateScoreKey: () => ({ source: "ANNOTATION" }),diff --git a/web/src/features/datasets/components/AnnotationPanel.tsx b/web/src/features/datasets/components/AnnotationPanel.tsxindex e6fda50ce3..3b2a1a3a9e 100644--- a/web/src/features/datasets/components/AnnotationPanel.tsx+++ b/web/src/features/datasets/components/AnnotationPanel.tsx@@ -6,12 +6,10 @@ import {} from "@/src/components/ui/resizable";import { Skeleton } from "@/src/components/ui/skeleton";import useSessionStorage from "@/src/components/useSessionStorage";-import { CommentsSection } from "@/src/features/annotation-queues";+import { CommentsSection } from "@/src/features/annotation-queues/components/shared/CommentsSection";import { useActiveCell } from "@/src/features/datasets/contexts/ActiveCellProvider";-import {- AnnotationForm,- decomposeAggregateScoreKey,-} from "@/src/features/scores";+import { AnnotationForm } from "@/src/features/scores/components/AnnotationForm";+import { decomposeAggregateScoreKey } from "@/src/features/scores/lib/aggregateScores";import { ChevronRight } from "@langfuse/icons";import { useCallback } from "react";diff --git a/web/src/features/datasets/components/CreateDatasetDialogController.tsx b/web/src/features/datasets/components/CreateDatasetDialogController.tsxindex 32c512a782..2e21e44756 100644--- a/web/src/features/datasets/components/CreateDatasetDialogController.tsx+++ b/web/src/features/datasets/components/CreateDatasetDialogController.tsx@@ -1,11 +1,11 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Dialog } from "@/src/components/ui/dialog";import {CreateDatasetDialogContent,type CreateDatasetDialogProps,} from "@/src/features/datasets/components/CreateDatasetDialogContent";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type ReactNode, useState } from "react";export function CreateDatasetDialogController({diff --git a/web/src/features/datasets/components/DatasetAggregateTableCell.tsx b/web/src/features/datasets/components/DatasetAggregateTableCell.tsxindex 42ee4acac3..22dcb573db 100644--- a/web/src/features/datasets/components/DatasetAggregateTableCell.tsx+++ b/web/src/features/datasets/components/DatasetAggregateTableCell.tsx@@ -10,14 +10,12 @@ import { cn } from "@/src/utils/tailwind";import { ClockIcon, ListTree } from "@langfuse/icons";import { usdFormatter } from "@/src/utils/numbers";import { type EnrichedDatasetRunItem } from "@langfuse/shared/src/server";-import {- type ScoreColumn,- ScoreRow,- useMergedAggregates,- useMergeScoreColumns,-} from "@/src/features/scores";+import type { ScoreColumn } from "@/src/features/scores/types";+import { ScoreRow } from "@/src/features/scores/components/ScoreRow";+import { useMergedAggregates } from "@/src/features/scores/lib/useMergedAggregates";+import { useMergeScoreColumns } from "@/src/features/scores/lib/mergeScoreColumns";import { useRouter } from "next/router";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useTrpcError } from "@/src/hooks/useTrpcError";import { type ScoreAggregate } from "@langfuse/shared";import { computeScoreDiffs } from "@/src/features/datasets/lib/computeScoreDiffs";@@ -26,7 +24,7 @@ import { type BaselineDiff } from "@/src/features/datasets/lib/calculateBaselineimport { DiffLabel } from "@/src/features/datasets/components/DiffLabel";import { useResourceMetricsDiff } from "@/src/features/datasets/hooks/useResourceMetricsDiff";import { NotFoundCard } from "@/src/features/datasets/components/NotFoundCard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";const DatasetAggregateCellContent = ({projectId,diff --git a/web/src/features/datasets/components/DatasetAnalytics.tsx b/web/src/features/datasets/components/DatasetAnalytics.tsxindex 823c98786d..2eb44f11fd 100644--- a/web/src/features/datasets/components/DatasetAnalytics.tsx+++ b/web/src/features/datasets/components/DatasetAnalytics.tsx@@ -1,7 +1,7 @@import { DropdownMenuItem } from "@/src/components/ui/dropdown-menu";-import { RESOURCE_METRICS } from "@/src/features/dashboard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { MultiSelectKeyValues } from "@/src/features/scores";+import { RESOURCE_METRICS } from "@/src/features/dashboard/lib/score-analytics-utils";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { MultiSelectKeyValues } from "@/src/features/scores/components/MultiSelectKeyValues";export function DatasetAnalytics(props: {scoreOptions: { key: string; value: string }[];diff --git a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx b/web/src/features/datasets/components/DatasetCompareRunsTable.tsxindex 6cf5f73b71..0a002f0935 100644--- a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx+++ b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx@@ -5,7 +5,7 @@ import { FilteredRunPills } from "@/src/components/table/FilteredRunPills";import { type LangfuseColumnDef } from "@/src/components/table/types";import { createLinkTableColumn } from "@/src/components/design-system/table/columns/createLinkTableColumn";import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";-import { useColumnVisibility } from "@/src/features/column-visibility";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { getDatasetRunAggregateColumnProps } from "@/src/features/datasets/components/DatasetRunAggregateColumnHelpers";import { useDatasetRunAggregateColumns } from "@/src/features/datasets/hooks/useDatasetRunAggregateColumns";import { useEffect, useMemo } from "react";@@ -16,12 +16,12 @@ import {customRowHeightMenu,useRowHeightLocalStorage,} from "@/src/components/table/data-table-row-height-switch";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import {DatasetCompareFieldsProvider,useDatasetCompareFields,} from "@/src/features/datasets/contexts/DatasetCompareFieldsProvider";-import { useColumnFilterState } from "@/src/features/filters";+import { useColumnFilterState } from "@/src/features/filters/hooks/useColumnFilterState";import { type Prisma } from "@langfuse/shared";import { type EnrichedDatasetRunItem } from "@langfuse/shared/src/server";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";diff --git a/web/src/features/datasets/components/DatasetForm.clienttest.tsx b/web/src/features/datasets/components/DatasetForm.clienttest.tsxindex c34fa768d2..3edaecb1d2 100644--- a/web/src/features/datasets/components/DatasetForm.clienttest.tsx+++ b/web/src/features/datasets/components/DatasetForm.clienttest.tsx@@ -26,13 +26,13 @@ vi.mock("@/src/utils/api", () => ({reportNonTrpcError: vi.fn(),}));vi.mock("next/router", () => ({ useRouter: () => ({ push }) }));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));vi.mock("@/src/hooks/useUniqueNameValidation", () => ({useUniqueNameValidation: vi.fn(),}));-vi.mock("@/src/components/editor", () => ({+vi.mock("@/src/components/editor/CodeMirrorEditor", () => ({CodeMirrorEditor: ({id,value,diff --git a/web/src/features/datasets/components/DatasetForm.tsx b/web/src/features/datasets/components/DatasetForm.tsxindex 2f26d3017a..fba0b458e4 100644--- a/web/src/features/datasets/components/DatasetForm.tsx+++ b/web/src/features/datasets/components/DatasetForm.tsx@@ -15,13 +15,13 @@ import {import { api, reportNonTrpcError } from "@/src/utils/api";import { useMemo, useState, useRef } from "react";import { Input } from "@/src/components/design-system/Input/Input";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import {DatasetNameSchema,isValidJSONSchema,type Prisma,} from "@langfuse/shared";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useRouter } from "next/router";import { useUniqueNameValidation } from "@/src/hooks/useUniqueNameValidation";import { DialogBody, DialogFooter } from "@/src/components/ui/dialog";diff --git a/web/src/features/datasets/components/DatasetItemDetailPage.tsx b/web/src/features/datasets/components/DatasetItemDetailPage.tsxindex 388319d1f7..b538568941 100644--- a/web/src/features/datasets/components/DatasetItemDetailPage.tsx+++ b/web/src/features/datasets/components/DatasetItemDetailPage.tsx@@ -1,10 +1,10 @@/* eslint-disable no-nested-ternary */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import Page from "@/src/components/layouts/Page";import { ActionButton } from "@/src/components/ActionButton";import { Button } from "@/src/components/ui/button";import { NewDatasetItemFromExistingObjectDialogController } from "@/src/features/datasets/components/NewDatasetItemFromExistingObjectDialogController";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import { api } from "@/src/utils/api";import {CopyIcon,@@ -16,7 +16,7 @@ import {import Link from "next/link";import { useRouter } from "next/router";import { DatasetStatus } from "@langfuse/shared";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {DropdownMenu,DropdownMenuContent,@@ -33,8 +33,9 @@ import {getDatasetItemTabs,DATASET_ITEM_TABS,type DatasetItemTab,-} from "@/src/features/navigation";-import { useExperimentAccess } from "@/src/features/experiments";+} from "@/src/features/navigation/utils/dataset-item-tabs";++import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";import { Skeleton } from "@/src/components/ui/skeleton";import { EditDatasetItemDialog } from "@/src/features/datasets/components/EditDatasetItemDialog";import { useDatasetVersion } from "@/src/features/datasets/hooks/useDatasetVersion";diff --git a/web/src/features/datasets/components/DatasetItemField.tsx b/web/src/features/datasets/components/DatasetItemField.tsxindex a67d955eb3..940fdba58a 100644--- a/web/src/features/datasets/components/DatasetItemField.tsx+++ b/web/src/features/datasets/components/DatasetItemField.tsx@@ -1,7 +1,7 @@import { useCallback, useMemo, useRef } from "react";import { type ReactCodeMirrorRef } from "@uiw/react-codemirror";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";import { MarkdownJsonViewHeader } from "@/src/components/ui/MarkdownJsonView";import { copyTextToClipboard } from "@/src/utils/clipboard";diff --git a/web/src/features/datasets/components/DatasetItemMediaAttachments.tsx b/web/src/features/datasets/components/DatasetItemMediaAttachments.tsxindex 7dafdb3521..c7f6b1fa2a 100644--- a/web/src/features/datasets/components/DatasetItemMediaAttachments.tsx+++ b/web/src/features/datasets/components/DatasetItemMediaAttachments.tsx@@ -5,13 +5,13 @@ import { type Extension } from "@codemirror/state";import { Check, Copy, Loader2, Paperclip } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";-import { createFileDropPasteExtension } from "@/src/components/editor";+import { createFileDropPasteExtension } from "@/src/components/editor/fileDropPaste";import { LangfuseMediaView } from "@/src/components/ui/LangfuseMediaView";import { type PendingMediaUpload } from "../hooks/useDatasetItemMediaUpload";-import {- type MediaContentType,- type MediaReturnType,-} from "@/src/features/media";+import type {+ MediaContentType,+ MediaReturnType,+} from "@/src/features/media/validation";import { api } from "@/src/utils/api";import { copyTextToClipboard } from "@/src/utils/clipboard";import {diff --git a/web/src/features/datasets/components/DatasetItemsTable.tsx b/web/src/features/datasets/components/DatasetItemsTable.tsxindex cc5b5747ca..9b31152713 100644--- a/web/src/features/datasets/components/DatasetItemsTable.tsx+++ b/web/src/features/datasets/components/DatasetItemsTable.tsx@@ -19,28 +19,27 @@ import {BatchExportTableName,} from "@langfuse/shared";import { type LangfuseColumnDef } from "@/src/components/table/types";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useEffect, useState } from "react";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import {customRowHeightMenu,isCompactRowHeight,useRowHeightLocalStorage,} from "@/src/components/table/data-table-row-height-switch";import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";-import { useQueryFilterState } from "@/src/features/filters";+import { useQueryFilterState } from "@/src/features/filters/hooks/useFilterState";import { useDebounce } from "@/src/hooks/useDebounce";-import { useFullTextSearch, TableSearchBar } from "@/src/features/search-bar";+import { useFullTextSearch } from "@/src/features/search-bar/hooks/useFullTextSearch";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";import { DATASET_ITEMS_FIELD_REGISTRY } from "../constants/datasetItemsSearchRegistry";import { useDatasetVersion } from "../hooks/useDatasetVersion";import { EditDatasetItemDialog } from "./EditDatasetItemDialog";diff --git a/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx b/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsxindex 63054468be..4ae1075467 100644--- a/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx+++ b/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx@@ -2,13 +2,13 @@ import { type LangfuseColumnDef } from "@/src/components/table/types";import { Skeleton } from "@/src/components/ui/skeleton";import { DatasetAggregateTableCell } from "@/src/features/datasets/components/DatasetAggregateTableCell";import { type DatasetCompareRunRowData } from "@/src/features/datasets/components/DatasetCompareRunsTable";-import { PopoverFilterBuilder } from "@/src/features/filters";+import { PopoverFilterBuilder } from "@/src/features/filters/components/filter-builder";import { type ColumnDefinition, type FilterState } from "@langfuse/shared";import { type EnrichedDatasetRunItem } from "@langfuse/shared/src/server";import { type Row } from "@tanstack/react-table";import React, { useEffect, useRef, useState } from "react";import { useDebounce } from "@/src/hooks/useDebounce";-import type { ScoreColumn } from "@/src/features/scores";+import type { ScoreColumn } from "@/src/features/scores/types";import { Toggle } from "@/src/components/design-system/Toggle/Toggle";import { useRouter } from "next/router";diff --git a/web/src/features/datasets/components/DatasetRunItemsByItemTable.tsx b/web/src/features/datasets/components/DatasetRunItemsByItemTable.tsxindex 2c00a656c7..ffa34d9d39 100644--- a/web/src/features/datasets/components/DatasetRunItemsByItemTable.tsx+++ b/web/src/features/datasets/components/DatasetRunItemsByItemTable.tsx@@ -6,12 +6,10 @@ import { api } from "@/src/utils/api";import { formatIntervalSeconds } from "@/src/utils/dates";import { usdFormatter } from "@/src/utils/numbers";import { useQueryParams, withDefault, NumberParam } from "use-query-params";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useEffect, useMemo } from "react";import {customRowHeightMenu,@@ -19,7 +17,8 @@ import {useRowHeightLocalStorage,} from "@/src/components/table/data-table-row-height-switch";import { ListTree } from "@langfuse/icons";-import { scoreFilters, useScoreColumns } from "@/src/features/scores";+import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";import { createIdTableColumn } from "@/src/components/design-system/table/columns/createIdTableColumn";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";diff --git a/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx b/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsxindex 347819b3b2..b6dc313c3b 100644--- a/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx+++ b/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx@@ -6,12 +6,10 @@ import { api } from "@/src/utils/api";import { formatIntervalSeconds } from "@/src/utils/dates";import { usdFormatter } from "@/src/utils/numbers";import { useQueryParams, withDefault, NumberParam } from "use-query-params";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useEffect, useMemo } from "react";import {customRowHeightMenu,@@ -19,7 +17,8 @@ import {useRowHeightLocalStorage,} from "@/src/components/table/data-table-row-height-switch";import { ListTree } from "@langfuse/icons";-import { scoreFilters, useScoreColumns } from "@/src/features/scores";+import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";import { Skeleton } from "@/src/components/ui/skeleton";import {DatasetItemIOCell,@@ -30,7 +29,7 @@ import { convertRunItemToItemsByRunUiTableRow } from "@/src/features/datasets/liimport { type DatasetRunItemByRunRowData } from "@/src/features/datasets/lib/types";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";-import { useQueryFilterState } from "@/src/features/filters";+import { useQueryFilterState } from "@/src/features/filters/hooks/useFilterState";import { useDebounce } from "@/src/hooks/useDebounce";export function DatasetRunItemsByRunTable(props: {diff --git a/web/src/features/datasets/components/DatasetRunsTable.tsx b/web/src/features/datasets/components/DatasetRunsTable.tsxindex 40288a1758..0877b13688 100644--- a/web/src/features/datasets/components/DatasetRunsTable.tsx+++ b/web/src/features/datasets/components/DatasetRunsTable.tsx@@ -3,7 +3,7 @@ import { DataTable } from "@/src/components/table/data-table";import { type LangfuseColumnDef } from "@/src/components/table/types";import { createDropdownTableColumn } from "@/src/components/design-system/table/columns/createDropdownTableColumn";import { createLinkTableColumn } from "@/src/components/design-system/table/columns/createLinkTableColumn";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { api } from "@/src/utils/api";import { formatIntervalSeconds } from "@/src/utils/dates";import { useQueryParams, withDefault, NumberParam } from "use-query-params";@@ -11,16 +11,14 @@ import { type RouterOutput } from "@/src/utils/types";import { useEffect, useMemo, useState } from "react";import { usdFormatter } from "@/src/utils/numbers";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import {type Prisma,datasetRunsTableColsWithOptions,type ScoreAggregate,} from "@langfuse/shared";-import { useQueryFilterState } from "@/src/features/filters";+import { useQueryFilterState } from "@/src/features/filters/hooks/useFilterState";import { useDebounce } from "@/src/hooks/useDebounce";import {customRowHeightMenu,@@ -46,19 +44,21 @@ import { Skeleton } from "@/src/components/ui/skeleton";import {RESOURCE_METRICS,transformAggregatedRunMetricsToChartData,+} from "@/src/features/dashboard/lib/score-analytics-utils";+import {compareViewChartDataToDataPoints,getCompareViewChartUnit,-} from "@/src/features/dashboard";-import { Chart } from "@/src/features/widgets";+} from "@/src/features/dashboard/lib/chart-data-adapters";+import { Chart } from "@/src/features/widgets/chart-library/Chart";import {addPrefixToScoreKeys,- CompareViewAdapter,convertScoreColumnsToAnalyticsData,- getScoreLabelFromKey,scoreFilters,- useScoreColumns,-} from "@/src/features/scores";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+} from "@/src/features/scores/lib/scoreColumns";+import { CompareViewAdapter } from "@/src/features/scores/adapters/index";+import { getScoreLabelFromKey } from "@/src/features/scores/lib/aggregateScores";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";@@ -69,7 +69,7 @@ import {} from "@/src/components/ui/resizable";import useSessionStorage from "@/src/components/useSessionStorage";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";type DatasetRunRowData = {diff --git a/web/src/features/datasets/components/DatasetSchemaHoverCard.tsx b/web/src/features/datasets/components/DatasetSchemaHoverCard.tsxindex 3e9e153e8e..970b313a5f 100644--- a/web/src/features/datasets/components/DatasetSchemaHoverCard.tsx+++ b/web/src/features/datasets/components/DatasetSchemaHoverCard.tsx@@ -1,6 +1,6 @@import { ArrowUpRight, LockIcon, Copy, Check } from "@langfuse/icons";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import type { Prisma } from "@langfuse/shared";import { Button } from "@/src/components/ui/button";import { Separator } from "@/src/components/ui/separator";diff --git a/web/src/features/datasets/components/DatasetVersionHistoryPanel.tsx b/web/src/features/datasets/components/DatasetVersionHistoryPanel.tsxindex 7d38724b80..e44d044be6 100644--- a/web/src/features/datasets/components/DatasetVersionHistoryPanel.tsx+++ b/web/src/features/datasets/components/DatasetVersionHistoryPanel.tsx@@ -20,7 +20,7 @@ import {formatDistanceToNow,} from "date-fns";import { cn } from "@/src/utils/tailwind";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";type DatasetVersionHistoryPanelProps = {projectId: string;diff --git a/web/src/features/datasets/components/DatasetsTable.tsx b/web/src/features/datasets/components/DatasetsTable.tsxindex a38ac6053e..1146cddd3a 100644--- a/web/src/features/datasets/components/DatasetsTable.tsx+++ b/web/src/features/datasets/components/DatasetsTable.tsx@@ -6,15 +6,13 @@ import { type LangfuseColumnDef } from "@/src/components/table/types";import { DeleteDatasetDialogController } from "@/src/features/datasets/components/DeleteDatasetDialogController";import { DatasetSchemaHoverCard } from "@/src/features/datasets/components/DatasetSchemaHoverCard";import { UpdateDatasetDialogController } from "@/src/features/datasets/components/UpdateDatasetDialogController";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { api } from "@/src/utils/api";import { withDefault, useQueryParam, StringParam } from "use-query-params";import { type RouterOutput } from "@/src/utils/types";import { useEffect, useMemo, useState } from "react";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import {TableViewPresetTableName,@@ -36,12 +34,10 @@ import { createNumberTableColumn } from "@/src/components/design-system/table/coimport { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";import { joinTableCoreAndMetrics } from "@/src/components/table/utils/joinTableCoreAndMetrics";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";-import {- useFolderPagination,- FolderBreadcrumb,- buildFullPath,-} from "@/src/features/folders";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useFolderPagination } from "@/src/features/folders/hooks/useFolderPagination";+import { FolderBreadcrumb } from "@/src/features/folders/components/FolderBreadcrumb";+import { buildFullPath } from "@/src/features/folders/utils";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {createDatasetsTableStore,toFolderRowId,@@ -49,12 +45,10 @@ import {} from "@/src/features/datasets/store/datasetsTableStore";import { useDatasetsTableSelectionSync } from "@/src/features/datasets/hooks/useDatasetsTableSelectionSync";import { useStore } from "zustand";-import {- TableSelectionManager,- TableActionMenu,- type TableAction,-} from "@/src/features/table";-import { showSuccessToast } from "@/src/features/notifications";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";+import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";+import type { TableAction } from "@/src/features/table/types";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { Pen, Trash } from "@langfuse/icons";type DatasetTableRow = {diff --git a/web/src/features/datasets/components/DeleteDatasetDialog.tsx b/web/src/features/datasets/components/DeleteDatasetDialog.tsxindex 3416177491..3cf2f226ee 100644--- a/web/src/features/datasets/components/DeleteDatasetDialog.tsx+++ b/web/src/features/datasets/components/DeleteDatasetDialog.tsx@@ -1,5 +1,5 @@import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { type ReactNode } from "react";import { useRouter } from "next/router";diff --git a/web/src/features/datasets/components/DeleteDatasetDialogController.tsx b/web/src/features/datasets/components/DeleteDatasetDialogController.tsxindex c1599a86f8..06211c15f4 100644--- a/web/src/features/datasets/components/DeleteDatasetDialogController.tsx+++ b/web/src/features/datasets/components/DeleteDatasetDialogController.tsx@@ -1,9 +1,9 @@-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {DeleteDatasetDialog,type DeleteDatasetDialogDataProps,} from "@/src/features/datasets/components/DeleteDatasetDialog";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type ReactNode } from "react";export type DeleteDatasetDialogSource = "dataset" | "table-single-row";diff --git a/web/src/features/datasets/components/DeleteDatasetRunDialogController.tsx b/web/src/features/datasets/components/DeleteDatasetRunDialogController.tsxindex 7e655a46dd..d70f7ef128 100644--- a/web/src/features/datasets/components/DeleteDatasetRunDialogController.tsx+++ b/web/src/features/datasets/components/DeleteDatasetRunDialogController.tsx@@ -1,6 +1,6 @@-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { useRouter } from "next/router";import type * as React from "react";diff --git a/web/src/features/datasets/components/DuplicateDatasetDialogController.tsx b/web/src/features/datasets/components/DuplicateDatasetDialogController.tsxindex cb6f8bb1ec..053a6a3c91 100644--- a/web/src/features/datasets/components/DuplicateDatasetDialogController.tsx+++ b/web/src/features/datasets/components/DuplicateDatasetDialogController.tsx@@ -2,7 +2,7 @@ import { useRouter } from "next/router";import { type ReactNode } from "react";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";export function DuplicateDatasetDialogController({diff --git a/web/src/features/datasets/components/EditDatasetItemDialog.tsx b/web/src/features/datasets/components/EditDatasetItemDialog.tsxindex 02a1e7e624..24ef32c10e 100644--- a/web/src/features/datasets/components/EditDatasetItemDialog.tsx+++ b/web/src/features/datasets/components/EditDatasetItemDialog.tsx@@ -14,7 +14,7 @@ import {DialogHeader,DialogTitle,} from "@/src/components/ui/dialog";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useDatasetItemValidation } from "../hooks/useDatasetItemValidation";import {useDatasetItemMediaUpload,diff --git a/web/src/features/datasets/components/NewDatasetItemButton.tsx b/web/src/features/datasets/components/NewDatasetItemButton.tsxindex ac9920cba7..52ec97b4a9 100644--- a/web/src/features/datasets/components/NewDatasetItemButton.tsx+++ b/web/src/features/datasets/components/NewDatasetItemButton.tsx@@ -9,7 +9,7 @@ import {import { useRef, useState } from "react";import { NewDatasetItemForm } from "@/src/features/datasets/components/NewDatasetItemForm";import { DialogTrigger } from "@radix-ui/react-dialog";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ActionButton } from "@/src/components/ActionButton";export const NewDatasetItemButton = (props: {diff --git a/web/src/features/datasets/components/NewDatasetItemForm.clienttest.tsx b/web/src/features/datasets/components/NewDatasetItemForm.clienttest.tsxindex ac580a5891..abee7b2f32 100644--- a/web/src/features/datasets/components/NewDatasetItemForm.clienttest.tsx+++ b/web/src/features/datasets/components/NewDatasetItemForm.clienttest.tsx@@ -45,10 +45,10 @@ vi.mock("@/src/utils/api", () => ({vi.mock("../lib/generateSchemaExample", () => ({generateSchemaExample: generateExample,}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));-vi.mock("@/src/components/editor", () => ({+vi.mock("@/src/components/editor/CodeMirrorEditor", () => ({CodeMirrorEditor: ({id,value,diff --git a/web/src/features/datasets/components/NewDatasetItemForm.tsx b/web/src/features/datasets/components/NewDatasetItemForm.tsxindex de966ea13f..5831bf46f0 100644--- a/web/src/features/datasets/components/NewDatasetItemForm.tsx+++ b/web/src/features/datasets/components/NewDatasetItemForm.tsx@@ -25,13 +25,13 @@ import {} from "react";import { useQuery } from "@tanstack/react-query";import { Skeleton } from "@/src/components/ui/skeleton";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { type ReactCodeMirrorRef } from "@uiw/react-codemirror";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { useMediaTagChips } from "@/src/components/editor/mediaTagWidget";import { type Prisma } from "@langfuse/shared";import { cn } from "@/src/utils/tailwind";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { DatasetSchemaHoverCard } from "./DatasetSchemaHoverCard";import { useDatasetItemValidation } from "../hooks/useDatasetItemValidation";import {diff --git a/web/src/features/datasets/components/PreviewCsvImport.tsx b/web/src/features/datasets/components/PreviewCsvImport.tsxindex b086759dac..c2fef72f6c 100644--- a/web/src/features/datasets/components/PreviewCsvImport.tsx+++ b/web/src/features/datasets/components/PreviewCsvImport.tsx@@ -11,7 +11,7 @@ import { useState, useEffect } from "react";import { Button } from "@/src/components/ui/button";import { api } from "@/src/utils/api";import { Progress } from "@/src/components/design-system/Progress/Progress";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { DialogBody, DialogFooter } from "@/src/components/ui/dialog";import { CsvImportValidationError } from "./CsvImportValidationError";import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";diff --git a/web/src/features/datasets/components/UpdateDatasetDialogController.tsx b/web/src/features/datasets/components/UpdateDatasetDialogController.tsxindex af460dde16..7af33b5d85 100644--- a/web/src/features/datasets/components/UpdateDatasetDialogController.tsx+++ b/web/src/features/datasets/components/UpdateDatasetDialogController.tsx@@ -1,11 +1,11 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Dialog } from "@/src/components/ui/dialog";import {UpdateDatasetDialogContent,type UpdateDatasetDialogProps,} from "@/src/features/datasets/components/UpdateDatasetDialogContent";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type ReactNode, useState } from "react";export type UpdateDatasetDialogSource = "dataset" | "table-single-row";diff --git a/web/src/features/datasets/components/UploadDatasetCsv.tsx b/web/src/features/datasets/components/UploadDatasetCsv.tsxindex 517398d345..9bae4620a2 100644--- a/web/src/features/datasets/components/UploadDatasetCsv.tsx+++ b/web/src/features/datasets/components/UploadDatasetCsv.tsx@@ -6,7 +6,7 @@ import {CardHeader,CardTitle,} from "@/src/components/ui/card";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { z } from "zod";import { parseCsvClient } from "@/src/features/datasets/lib/csv/helpers";import { DialogBody } from "@/src/components/ui/dialog";diff --git a/web/src/features/datasets/components/UploadDatasetCsvButton.tsx b/web/src/features/datasets/components/UploadDatasetCsvButton.tsxindex 1da269ae19..3757d8d2a2 100644--- a/web/src/features/datasets/components/UploadDatasetCsvButton.tsx+++ b/web/src/features/datasets/components/UploadDatasetCsvButton.tsx@@ -1,7 +1,7 @@import { UploadIcon } from "@langfuse/icons";import { DialogTrigger } from "@radix-ui/react-dialog";import { useState } from "react";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ActionButton } from "@/src/components/ActionButton";import { CsvUploadDialog } from "@/src/features/datasets/components/CsvUploadDialog";diff --git a/web/src/features/datasets/constants/datasetItemsSearchRegistry.clienttest.ts b/web/src/features/datasets/constants/datasetItemsSearchRegistry.clienttest.tsindex 96f49ef24b..b55f6e70d0 100644--- a/web/src/features/datasets/constants/datasetItemsSearchRegistry.clienttest.ts+++ b/web/src/features/datasets/constants/datasetItemsSearchRegistry.clienttest.ts@@ -1,13 +1,13 @@import { describe, expect, it } from "vitest";import type { FilterState } from "@langfuse/shared";import { DATASET_ITEMS_FIELD_REGISTRY } from "./datasetItemsSearchRegistry";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";import {- planCommit,- filterStateToQueryText,applyPick,planInputCompletions,- runSearchBarInvariants,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/lib/completions";+import { runSearchBarInvariants } from "@/src/features/search-bar/lib/searchBarInvariants";const registry = DATASET_ITEMS_FIELD_REGISTRY;const metadataFilter: FilterState = [diff --git a/web/src/features/datasets/constants/datasetItemsSearchRegistry.ts b/web/src/features/datasets/constants/datasetItemsSearchRegistry.tsindex d26de1b658..6bda139897 100644--- a/web/src/features/datasets/constants/datasetItemsSearchRegistry.ts+++ b/web/src/features/datasets/constants/datasetItemsSearchRegistry.ts@@ -1,5 +1,5 @@import { datasetItemFilterColumns } from "@langfuse/shared";-import { fieldRegistryFromColumns } from "@/src/features/search-bar";+import { fieldRegistryFromColumns } from "@/src/features/search-bar/lib/fields";export const DATASET_ITEMS_FIELD_REGISTRY = fieldRegistryFromColumns(datasetItemFilterColumns,diff --git a/web/src/features/datasets/contexts/ActiveCellProvider.tsx b/web/src/features/datasets/contexts/ActiveCellProvider.tsxindex 909d493c4b..c05b2c0226 100644--- a/web/src/features/datasets/contexts/ActiveCellProvider.tsx+++ b/web/src/features/datasets/contexts/ActiveCellProvider.tsx@@ -2,7 +2,7 @@ import { type ScoreAggregate } from "@langfuse/shared";import { createContext, useContext, useState, type ReactNode } from "react";import { useStore } from "zustand";import { createStore } from "zustand/vanilla";-import { showToast } from "@/src/features/notifications";+import { showToast } from "@/src/features/notifications/showToast";type ActiveCell = {datasetRunId: string;diff --git a/web/src/features/datasets/hooks/useCsvImport.ts b/web/src/features/datasets/hooks/useCsvImport.tsindex b3cad4fa8e..3659d34b82 100644--- a/web/src/features/datasets/hooks/useCsvImport.ts+++ b/web/src/features/datasets/hooks/useCsvImport.ts@@ -1,6 +1,6 @@import { useState } from "react";import { type RouterInputs, api } from "@/src/utils/api";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { MAX_FILE_SIZE_BYTES } from "@/src/features/datasets/components/UploadDatasetCsv";import { type BulkDatasetItemValidationError } from "@langfuse/shared";diff --git a/web/src/features/datasets/hooks/useDatasetItemMediaUpload.ts b/web/src/features/datasets/hooks/useDatasetItemMediaUpload.tsindex 41f4fb031d..0b22a9ad8f 100644--- a/web/src/features/datasets/hooks/useDatasetItemMediaUpload.ts+++ b/web/src/features/datasets/hooks/useDatasetItemMediaUpload.ts@@ -1,9 +1,9 @@import { Sha256 } from "@aws-crypto/sha256-browser";import { useCallback, useState } from "react";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import type { ToastErrorAnalytics } from "@/src/features/notifications/toastAnalytics";-import { MediaContentType } from "@/src/features/media";+import { MediaContentType } from "@/src/features/media/validation";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { safeRandomUUID } from "@/src/utils/safe-random-uuid";diff --git a/web/src/features/datasets/hooks/useDatasetRunAggregateColumns.ts b/web/src/features/datasets/hooks/useDatasetRunAggregateColumns.tsindex 6513095f45..d41fcc11dc 100644--- a/web/src/features/datasets/hooks/useDatasetRunAggregateColumns.ts+++ b/web/src/features/datasets/hooks/useDatasetRunAggregateColumns.ts@@ -5,7 +5,7 @@ import {datasetRunItemsTableColsWithOptions,type FilterState,} from "@langfuse/shared";-import { scoreFilters } from "@/src/features/scores";+import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";export function useDatasetRunAggregateColumns({projectId,diff --git a/web/src/features/datasets/hooks/useDatasetRunCompareChartData.ts b/web/src/features/datasets/hooks/useDatasetRunCompareChartData.tsindex b41c1e1c66..966e030d7d 100644--- a/web/src/features/datasets/hooks/useDatasetRunCompareChartData.ts+++ b/web/src/features/datasets/hooks/useDatasetRunCompareChartData.ts@@ -3,8 +3,8 @@ import { useMemo } from "react";import {convertScoreColumnsToAnalyticsData,scoreFilters,-} from "@/src/features/scores";-import { transformAggregatedRunMetricsToChartData } from "@/src/features/dashboard";+} from "@/src/features/scores/lib/scoreColumns";+import { transformAggregatedRunMetricsToChartData } from "@/src/features/dashboard/lib/score-analytics-utils";export function useDatasetRunCompareChartData(projectId: string,diff --git a/web/src/features/datasets/index.ts b/web/src/features/datasets/index.tsdeleted file mode 100644index 65c90e4d77..0000000000--- a/web/src/features/datasets/index.ts+++ /dev/null@@ -1,10 +0,0 @@-// The datasets feature's public client surface (RFC rule 8). Named re-exports-// only — exactly what other features already imported. The public-API dataset-// services live behind server/index.ts.-export { DatasetForm } from "@/src/features/datasets/components/DatasetForm";-export { DatasetSchemaHoverCard } from "@/src/features/datasets/components/DatasetSchemaHoverCard";-export { DiffLabel } from "@/src/features/datasets/components/DiffLabel";-export { NewDatasetItemFromExistingObjectDialogController } from "@/src/features/datasets/components/NewDatasetItemFromExistingObjectDialogController";-export { calculateNumericDiff } from "@/src/features/datasets/lib/calculateBaselineDiff";-export type { BaselineDiff } from "@/src/features/datasets/lib/calculateBaselineDiff";-export { computeScoreDiffs } from "@/src/features/datasets/lib/computeScoreDiffs";diff --git a/web/src/features/datasets/server/dataset-router.ts b/web/src/features/datasets/server/dataset-router.tsindex a6e9359b88..abf312a6cb 100644--- a/web/src/features/datasets/server/dataset-router.ts+++ b/web/src/features/datasets/server/dataset-router.ts@@ -7,14 +7,14 @@ import {} from "@/src/server/api/trpc";import { Prisma, type Dataset } from "@langfuse/shared/src/db";import { env as sharedEnv } from "@langfuse/shared/src/env";-import { throwIfNoProjectAccess } from "@/src/features/rbac";-import { auditLog } from "@/src/features/audit-logs/server";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { createMediaUploadUrl } from "@/src/features/media/server/mediaService";import {- createMediaUploadUrl,datasetItemMediaReferenceKey,resolveDatasetItemMediaReferences,- MediaContentType,-} from "@/src/features/media/server";+} from "@/src/features/media/server/datasetItemMediaReferences";+import { MediaContentType } from "@/src/features/media/validation";import {paginationZod,singleFilterList,@@ -94,7 +94,7 @@ import {deleteDatasetsByIds,findDatasetsForDeletion,} from "@langfuse/shared/src/server";-import { aggregateScores } from "@/src/features/scores/server";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";import {updateDataset,upsertDataset,@@ -109,7 +109,7 @@ import {RemoteExperimentHeadersSchema,} from "@/src/features/datasets/server/remoteExperimentHelpers";import { v4 } from "uuid";-import { createBatchActionJob } from "@/src/features/table/server";+import { createBatchActionJob } from "@/src/features/table/server/createBatchActionJob";// Batch size kept small (100) as items may have large input/output/metadata JSONconst DUPLICATE_DATASET_ITEMS_BATCH_SIZE = 100;diff --git a/web/src/features/datasets/server/index.ts b/web/src/features/datasets/server/index.tsdeleted file mode 100644index 857bb482f7..0000000000--- a/web/src/features/datasets/server/index.ts+++ /dev/null@@ -1,16 +0,0 @@-// The datasets feature's server surface (RFC rule 9, amended): the services-// the public REST API and MCP tools call.-export {- createDatasetForApi,- createDatasetItemForApi,- createDatasetRunItemForApi,- deleteDatasetItemForApi,- deleteDatasetRunByIdForApi,- getDatasetByIdForApi,- getDatasetItemForApi,- getDatasetRunByIdForApi,- listDatasetItemsForApi,- listDatasetRunItemsByRunIdForApi,- listDatasetRunsByDatasetIdForApi,- listDatasetsForApi,-} from "@/src/features/datasets/server/publicDatasetService";diff --git a/web/src/features/datasets/server/publicDatasetService.ts b/web/src/features/datasets/server/publicDatasetService.tsindex 5c4adf46ec..df8f0419b4 100644--- a/web/src/features/datasets/server/publicDatasetService.ts+++ b/web/src/features/datasets/server/publicDatasetService.ts@@ -2,12 +2,30 @@ import type { NextApiResponse } from "next";import { createHash } from "node:crypto";import { v4 } from "uuid";import { omit } from "lodash";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { addDatasetRunItemsToEvalQueue } from "@/src/features/evals/server/addDatasetRunItemsToEvalQueue";import {createOrFetchDatasetRun,+ addToDeleteDatasetQueue,+ createDatasetItemFilterState,+ createUnknownSdkIngestionAttribution,+ deleteDatasetItem,+ escapeSqlLikePattern,+ eventTypes,+ getDatasetItemById,+ getDatasetItems,+ getDatasetItemsCount,+ getObservationById,+ logger,+ processEventBatch,+ type AuthHeaderValidVerificationResultIngestion,+ upsertDatasetItem,+} from "@langfuse/shared/src/server";+import {generateDatasetRunItemsForPublicApi,getDatasetRunItemsCountForPublicApi,+} from "@/src/features/public-api/server/dataset-run-items";+import {type APIDatasetRunItem,type GetDatasetsV1Query,type GetDatasetV1Query,@@ -24,7 +42,8 @@ import {transformDbDatasetItemDomainToAPIDatasetItem,transformDbDatasetRunToAPIDatasetRun,transformDbDatasetToAPIDataset,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/datasets";+import {ApiError,type JSONValue,@@ -38,24 +57,9 @@ import { env } from "@/src/env.mjs";import {datasetItemMediaReferenceKey,resolveDatasetItemMediaReferences,-} from "@/src/features/media/server";+} from "@/src/features/media/server/datasetItemMediaReferences";import { upsertDataset } from "./actions/createDataset";-import {- addToDeleteDatasetQueue,- createDatasetItemFilterState,- createUnknownSdkIngestionAttribution,- deleteDatasetItem,- escapeSqlLikePattern,- eventTypes,- getDatasetItemById,- getDatasetItems,- getDatasetItemsCount,- getObservationById,- logger,- processEventBatch,- type AuthHeaderValidVerificationResultIngestion,- upsertDatasetItem,-} from "@langfuse/shared/src/server";+import type { z } from "zod";type DatasetAuditScope = {diff --git a/web/src/features/datasets/server/service.ts b/web/src/features/datasets/server/service.tsindex 83e94d5632..c3ea703106 100644--- a/web/src/features/datasets/server/service.ts+++ b/web/src/features/datasets/server/service.ts@@ -21,7 +21,7 @@ import {} from "@langfuse/shared/src/server";import Decimal from "decimal.js";import groupBy from "lodash/groupBy";-import { aggregateScores } from "@/src/features/scores/server";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";import { calculateRecursiveMetricsForRunItems } from "./utils";export const datasetRunsTableSchema = z.object({diff --git a/web/src/features/datasets/store/datasetsTableStore.ts b/web/src/features/datasets/store/datasetsTableStore.tsindex 99aed2ea18..65b99b91fd 100644--- a/web/src/features/datasets/store/datasetsTableStore.ts+++ b/web/src/features/datasets/store/datasetsTableStore.ts@@ -2,7 +2,7 @@ import { createStore, type StoreApi } from "zustand/vanilla";import { type RowSelectionState, type Updater } from "@tanstack/react-table";import { type TableSelectionStoreState } from "@/src/components/table/table-selection-store";import { type RouterInput } from "@/src/utils/types";-import { type usePostHogClientCapture } from "@/src/features/posthog-analytics";+import type { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";type RowSelectionUpdater = Updater<RowSelectionState>;type BooleanUpdater = Updater<boolean>;diff --git a/web/src/features/datasets/utils/datasetItemUtils.ts b/web/src/features/datasets/utils/datasetItemUtils.tsindex 0ca01b9b8d..477e353071 100644--- a/web/src/features/datasets/utils/datasetItemUtils.ts+++ b/web/src/features/datasets/utils/datasetItemUtils.ts@@ -1,4 +1,4 @@-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import type { Prisma } from "@langfuse/shared";/**diff --git a/web/src/features/datasets/utils/getDatasetBreadcrumb.ts b/web/src/features/datasets/utils/getDatasetBreadcrumb.tsindex 7239443f28..25f7764816 100644--- a/web/src/features/datasets/utils/getDatasetBreadcrumb.ts+++ b/web/src/features/datasets/utils/getDatasetBreadcrumb.ts@@ -1,4 +1,4 @@-import { createBreadcrumbItems } from "@/src/features/folders";+import { createBreadcrumbItems } from "@/src/features/folders/utils";export const getDatasetBreadcrumb = (projectId: string,diff --git a/web/src/features/datasets/utils/parseDatasetJson.clienttest.ts b/web/src/features/datasets/utils/parseDatasetJson.clienttest.tsindex 85b4801b30..76db285411 100644--- a/web/src/features/datasets/utils/parseDatasetJson.clienttest.ts+++ b/web/src/features/datasets/utils/parseDatasetJson.clienttest.ts@@ -8,7 +8,9 @@ import {parseDatasetJson,} from "./parseDatasetJson";-vi.mock("@/src/features/notifications", () => ({ showErrorToast: vi.fn() }));+vi.mock("@/src/features/notifications/showErrorToast", () => ({+ showErrorToast: vi.fn(),+}));describe("dataset item JSON round trip", () => {it.each([0, false, ""])("preserves the scalar %j", (value) => {diff --git a/web/src/features/developer-tools/index.ts b/web/src/features/developer-tools/index.tsdeleted file mode 100644index caf7379e3d..0000000000--- a/web/src/features/developer-tools/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { AgentToolsBanner } from "@/src/features/developer-tools/components/AgentToolsBanner";-export { DeveloperToolsSettings } from "@/src/features/developer-tools/components/DeveloperToolsSettings";diff --git a/web/src/features/entitlements/index.ts b/web/src/features/entitlements/index.tsdeleted file mode 100644index f6f1bdec44..0000000000--- a/web/src/features/entitlements/index.ts+++ /dev/null@@ -1,12 +0,0 @@-// The entitlements feature's public client surface (RFC rule 8): the React-// hooks only. Everything that reads a plan on the server lives behind-// server/index.ts so that importing this file cannot pull server code into a-// client bundle.-export type { Entitlement } from "@/src/features/entitlements/constants/entitlements";-export {- useEntitlementLimit,- useEntitlements,- useHasEntitlement,- useOptionalEntitlement,- usePlan,-} from "@/src/features/entitlements/hooks";diff --git a/web/src/features/entitlements/server/index.ts b/web/src/features/entitlements/server/index.tsdeleted file mode 100644index 784b0f37ff..0000000000--- a/web/src/features/entitlements/server/index.ts+++ /dev/null@@ -1,15 +0,0 @@-// The entitlements feature's server surface (RFC rule 9, amended).-export { createWithinEntitlementLimit } from "@/src/features/entitlements/server/createWithinEntitlementLimit";-export {- getOrganizationPlanServerSide,- getSelfHostedInstancePlanServerSide,-} from "@/src/features/entitlements/server/getPlan";-export {- hasEntitlement,- hasEntitlementBasedOnPlan,- throwIfNoEntitlement,-} from "@/src/features/entitlements/server/hasEntitlement";-export {- clampToDataAccessDays,- hasEntitlementLimit,-} from "@/src/features/entitlements/server/hasEntitlementLimit";diff --git a/web/src/features/evals/components/CodeEvalTemplateFormBody.tsx b/web/src/features/evals/components/CodeEvalTemplateFormBody.tsxindex fc0504099e..92746609d6 100644--- a/web/src/features/evals/components/CodeEvalTemplateFormBody.tsx+++ b/web/src/features/evals/components/CodeEvalTemplateFormBody.tsx@@ -1,5 +1,5 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import CodeMirror, {Decoration,EditorView,diff --git a/web/src/features/evals/components/CodeEvalTestRunCard.tsx b/web/src/features/evals/components/CodeEvalTestRunCard.tsxindex 52cc081ad6..3ee03e9431 100644--- a/web/src/features/evals/components/CodeEvalTestRunCard.tsx+++ b/web/src/features/evals/components/CodeEvalTestRunCard.tsx@@ -1,5 +1,5 @@import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { TablePeekViewTraceDetail } from "@/src/components/table/peek/TablePeekViewTraceDetail";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";import { Badge } from "@/src/components/design-system/Badge/Badge";@@ -12,8 +12,8 @@ import {usePreviewData,} from "@/src/features/evals/hooks/usePreviewData";import { useFirstEvalPreviewPointer } from "@/src/features/evals/hooks/useEvalPreviewNavigation";-import { useReadPath } from "@/src/features/events";-import { detailPageListKeys } from "@/src/features/navigate-detail-pages";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { detailPageListKeys } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { api, type RouterOutputs } from "@/src/utils/api";import {deepParseJson,@@ -24,7 +24,7 @@ import {import { ExternalLink, ListTree, Play, RotateCcw } from "@langfuse/icons";import Link from "next/link";import { useMemo } from "react";-import { showToast } from "@/src/features/notifications";+import { showToast } from "@/src/features/notifications/showToast";import { type EvalFormType } from "@/src/features/evals/utils/evaluator-form-utils";diff --git a/web/src/features/evals/components/DeactivateEvalConfig.tsx b/web/src/features/evals/components/DeactivateEvalConfig.tsxindex 8fc29b1134..d561a381de 100644--- a/web/src/features/evals/components/DeactivateEvalConfig.tsx+++ b/web/src/features/evals/components/DeactivateEvalConfig.tsx@@ -1,7 +1,7 @@/* eslint-disable @repo/no-abstracted-overlay-trigger */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { EvaluatorStatus } from "@/src/features/evals/types";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api, type RouterOutputs } from "@/src/utils/api";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { Switch } from "@/src/components/design-system/Switch/Switch";diff --git a/web/src/features/evals/components/DeleteEvalTemplateDialog.tsx b/web/src/features/evals/components/DeleteEvalTemplateDialog.tsxindex c2dba9ee42..d8bae9be3d 100644--- a/web/src/features/evals/components/DeleteEvalTemplateDialog.tsx+++ b/web/src/features/evals/components/DeleteEvalTemplateDialog.tsx@@ -6,7 +6,8 @@ import { useState } from "react";import { ConfirmDialog } from "@/src/components/ui/ConfirmDialog";import { Input } from "@/src/components/ui/input";import { Label } from "@/src/components/ui/label";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/evals/components/EvalLogTable.tsx b/web/src/features/evals/components/EvalLogTable.tsxindex a3e9ce543e..75357c70f5 100644--- a/web/src/features/evals/components/EvalLogTable.tsx+++ b/web/src/features/evals/components/EvalLogTable.tsx@@ -18,15 +18,14 @@ import { createDateTableColumn } from "@/src/components/design-system/table/coluimport { createIdTableColumn } from "@/src/components/design-system/table/columns/createIdTableColumn";import { createLinkTableColumn } from "@/src/components/design-system/table/columns/createLinkTableColumn";import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";-import { TableSearchBar, toObservedOptions } from "@/src/features/search-bar";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { EVAL_LOGS_FIELD_REGISTRY } from "@/src/features/evals/constants/tableSearchRegistry";import { evalLogFilterConfig } from "@/src/features/filters/config/eval-logs-config";-import { useSidebarFilterState } from "@/src/features/filters";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";import { type RouterOutputs, api } from "@/src/utils/api";import { safeExtract } from "@/src/utils/map-utils";import { JobExecutionStatus, type Prisma } from "@langfuse/shared";diff --git a/web/src/features/evals/components/EvalTemplateDetail.tsx b/web/src/features/evals/components/EvalTemplateDetail.tsxindex 5e9bab21a1..6a5507a2f7 100644--- a/web/src/features/evals/components/EvalTemplateDetail.tsx+++ b/web/src/features/evals/components/EvalTemplateDetail.tsx@@ -1,11 +1,11 @@/* eslint-disable no-nested-ternary */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import * as React from "react";import { EvalTemplateForm } from "@/src/features/evals/components/EvalTemplateForm";import { api } from "@/src/utils/api";import { type EvalTemplate } from "@langfuse/shared";import { useRouter } from "next/router";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import Page from "@/src/components/layouts/Page";import { Switch } from "@/src/components/design-system/Switch/Switch";import { Command } from "@/src/components/ui/command";diff --git a/web/src/features/evals/components/EvalTemplateForm.tsx b/web/src/features/evals/components/EvalTemplateForm.tsxindex 3d96ec4787..94c2675b9e 100644--- a/web/src/features/evals/components/EvalTemplateForm.tsx+++ b/web/src/features/evals/components/EvalTemplateForm.tsx@@ -36,17 +36,17 @@ import {} from "@langfuse/shared";import router from "next/router";import { ModelParameters } from "@/src/components/ModelParameters";-import { PromptVariableListPreview } from "@/src/features/prompts";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { PromptVariableListPreview } from "@/src/features/prompts/components/PromptVariableListPreview";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { getFinalModelParams } from "@/src/utils/getFinalModelParams";-import { useModelParams } from "@/src/features/playground";-import { showSuccessToast } from "@/src/features/notifications";+import { useModelParams } from "@/src/features/playground/page/hooks/useModelParams";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import {getDefaultOutputDefinitionFormValues,shouldReplaceDefaultOutputDefinitionField,} from "@/src/features/evals/utils/template-form-defaults";import { templateFormSchema } from "@/src/features/evals/utils/template-form-schema";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { Card, CardContent } from "@/src/components/ui/card";import { type RouterInput } from "@/src/utils/types";import { useEvaluationModel } from "@/src/features/evals/hooks/useEvaluationModel";diff --git a/web/src/features/evals/components/EvalsTemplateTable.tsx b/web/src/features/evals/components/EvalsTemplateTable.tsxindex 2ef1693cb5..26c1568ffb 100644--- a/web/src/features/evals/components/EvalsTemplateTable.tsx+++ b/web/src/features/evals/components/EvalsTemplateTable.tsx@@ -3,7 +3,7 @@ import { DataTable } from "@/src/components/table/data-table";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import { type LangfuseColumnDef } from "@/src/components/table/types";import { type CustomHeights } from "@/src/components/table/data-table-row-height-switch";-import { useColumnVisibility } from "@/src/features/column-visibility";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { type RouterOutputs, api } from "@/src/utils/api";import { safeExtract } from "@/src/utils/map-utils";import { createColumnHelper } from "@tanstack/react-table";@@ -13,7 +13,7 @@ import { useEffect, useMemo, useState } from "react";import { usePaginationState } from "@/src/hooks/usePaginationState";import { TablePeekViewEvaluatorTemplateDetail } from "@/src/components/table/peek/TablePeekViewEvaluatorTemplateDetail";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { Button } from "@/src/components/ui/button";import { useRouter } from "next/router";import {@@ -30,9 +30,9 @@ import {DropdownMenuTrigger,} from "@/src/components/ui/dropdown-menu";import { DeleteEvalTemplateDialog } from "@/src/features/evals/components/DeleteEvalTemplateDialog";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { EvalTemplateForm } from "@/src/features/evals/components/EvalTemplateForm";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import {type TemplateValidationInput,useSingleTemplateValidation,@@ -40,8 +40,8 @@ import {import { getMaintainer } from "@/src/features/evals/utils/typeHelpers";import { MaintainerTooltip } from "@/src/features/evals/components/MaintainerTooltip";import { ActionButton } from "@/src/components/ActionButton";-import { useEntitlementLimit } from "@/src/features/entitlements";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Badge } from "@/src/components/design-system/Badge/Badge";import { getTemplateResultType } from "@/src/features/evals/utils/template-output";import {diff --git a/web/src/features/evals/components/EvaluatorDetail.tsx b/web/src/features/evals/components/EvaluatorDetail.tsxindex f95005de3d..d2980531d9 100644--- a/web/src/features/evals/components/EvaluatorDetail.tsx+++ b/web/src/features/evals/components/EvaluatorDetail.tsx@@ -3,7 +3,7 @@ import { api } from "@/src/utils/api";import { useRouter } from "next/router";import EvalLogTable from "@/src/features/evals/components/EvalLogTable";import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import Page from "@/src/components/layouts/Page";import { LevelCountsDisplay } from "@/src/components/LevelCountsDisplay";import { generateJobExecutionCounts } from "@/src/features/evals/utils/job-execution-utils";diff --git a/web/src/features/evals/components/EvaluatorFilterCell.tsx b/web/src/features/evals/components/EvaluatorFilterCell.tsxindex 87edb5cfe0..ece3130664 100644--- a/web/src/features/evals/components/EvaluatorFilterCell.tsx+++ b/web/src/features/evals/components/EvaluatorFilterCell.tsx@@ -1,6 +1,6 @@import type { FilterState } from "@langfuse/shared";import { formatFilterPreview } from "@/src/components/table/table-view-presets/lib/viewPreview";-import { InlineFilterState } from "@/src/features/filters";+import { InlineFilterState } from "@/src/features/filters/components/filter-builder";export function EvaluatorFilterCell({filterState,diff --git a/web/src/features/evals/components/EvaluatorPausedCallout.tsx b/web/src/features/evals/components/EvaluatorPausedCallout.tsxindex 4b9ef61fec..61beffacbb 100644--- a/web/src/features/evals/components/EvaluatorPausedCallout.tsx+++ b/web/src/features/evals/components/EvaluatorPausedCallout.tsx@@ -1,5 +1,6 @@import { Button } from "@/src/components/ui/button";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { formatDistanceToNow } from "date-fns";diff --git a/web/src/features/evals/components/EvaluatorTable.tsx b/web/src/features/evals/components/EvaluatorTable.tsxindex 4392c6e003..d54d8f6a19 100644--- a/web/src/features/evals/components/EvaluatorTable.tsx+++ b/web/src/features/evals/components/EvaluatorTable.tsx@@ -9,14 +9,15 @@ import {} from "@/src/components/table/data-table-controls";import { SearchableTableFilterLayout } from "@/src/components/table/resizable-filter-layout";import { type LangfuseColumnDef } from "@/src/components/table/types";-import { useColumnVisibility } from "@/src/features/column-visibility";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { EvaluatorFilterCell } from "@/src/features/evals/components/EvaluatorFilterCell";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";-import { TableSearchBar, toObservedOptions } from "@/src/features/search-bar";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { LEGACY_EVALUATORS_FIELD_REGISTRY } from "@/src/features/evals/constants/tableSearchRegistry";import { evaluatorFilterConfig } from "@/src/features/filters/config/evaluators-config";-import { useSidebarFilterState } from "@/src/features/filters";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";import { api } from "@/src/utils/api";import { createColumnHelper } from "@tanstack/react-table";import { useCallback, useEffect, useState, useMemo } from "react";@@ -24,7 +25,7 @@ import { useQueryParam, StringParam, withDefault } from "use-query-params";import { usePaginationState } from "@/src/hooks/usePaginationState";import { isEventTarget } from "@/src/features/evals/utils/typeHelpers";import { useEvalCapabilities } from "@/src/features/evals/hooks/useEvalCapabilities";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { IdTableCell } from "@/src/components/design-system/table/components/IdTableCell/IdTableCell";import { ExternalLinkIcon, Pen } from "@langfuse/icons";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";@@ -35,7 +36,7 @@ import {} from "@/src/server/api/definitions/evalConfigsTable";import { Button } from "@/src/components/ui/button";import { IconOnlyButton } from "@/src/components/IconOnlyButton";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import {Dialog,DialogContent,@@ -49,7 +50,7 @@ import {import { useRouter } from "next/router";import { DeleteEvalConfigButton } from "@/src/components/deleteButton";import { MaintainerTooltip } from "@/src/features/evals/components/MaintainerTooltip";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Skeleton } from "@/src/components/ui/skeleton";import { usdFormatter } from "@/src/utils/numbers";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";@@ -61,7 +62,7 @@ import {useEvaluatorTableData,} from "@/src/features/evals/hooks/useEvaluatorTableData";import { Spinner } from "@/src/components/design-system/Spinner/Spinner";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { V4MigrationBadgeContent } from "@/src/features/v4-migration/V4MigrationBadgeContent";import { buildEvaluatorUpgradeUrl } from "@/src/features/v4-migration/evaluatorMigrationUrls";diff --git a/web/src/features/evals/components/InnerEvaluatorForm.tsx b/web/src/features/evals/components/InnerEvaluatorForm.tsxindex 56675f8875..714d9c86cc 100644--- a/web/src/features/evals/components/InnerEvaluatorForm.tsx+++ b/web/src/features/evals/components/InnerEvaluatorForm.tsx@@ -37,13 +37,13 @@ import {import { z } from "zod";import { useEffect, useMemo, useState, memo, Suspense, lazy } from "react";import { api } from "@/src/utils/api";-import { InlineFilterBuilder } from "@/src/features/filters";+import { InlineFilterBuilder } from "@/src/features/filters/components/filter-builder";import { useRouter } from "next/router";import { TRPCClientError } from "@trpc/client";import { reportError } from "@/src/utils/reportError";import { Slider } from "@/src/components/ui/Slider";import { Card } from "@/src/components/ui/card";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";import { Switch } from "@/src/components/design-system/Switch/Switch";import {@@ -110,7 +110,7 @@ import {} from "@/src/features/evals/utils/evaluator-constants";import { useEvalConfigFilterOptions } from "@/src/features/evals/hooks/useEvalConfigFilterOptions";import { VariableMappingCard } from "@/src/features/evals/components/VariableMappingCard";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { useIsCodeEvalEnabled } from "@/src/features/evals/hooks/useIsCodeEvalEnabled";import {isCodeEvalTemplate,@@ -123,10 +123,8 @@ import { PeekTableStateProvider } from "@/src/components/table/peek/contexts/Pee// Lazy load tablesconst TracesTable = lazy(() => import("@/src/features/traces/TracesTable"));-const ObservationsTable = lazy(() =>- import("@/src/features/tracing-tables").then((m) => ({- default: m.ObservationsTable,- })),+const ObservationsTable = lazy(+ () => import("@/src/features/tracing-tables/observations/ObservationsTable"),);const EventsTable = lazy(diff --git a/web/src/features/evals/components/ManageDefaultEvalModel.tsx b/web/src/features/evals/components/ManageDefaultEvalModel.tsxindex cc14578d64..822e84ec77 100644--- a/web/src/features/evals/components/ManageDefaultEvalModel.tsx+++ b/web/src/features/evals/components/ManageDefaultEvalModel.tsx@@ -1,6 +1,6 @@/* eslint-disable @repo/no-style-props */import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { cn } from "@/src/utils/tailwind";import { Check, Pencil, TriangleAlert } from "@langfuse/icons";diff --git a/web/src/features/evals/components/SelectEvaluatorList.tsx b/web/src/features/evals/components/SelectEvaluatorList.tsxindex 940e1af5c2..f071fc79a3 100644--- a/web/src/features/evals/components/SelectEvaluatorList.tsx+++ b/web/src/features/evals/components/SelectEvaluatorList.tsx@@ -15,7 +15,7 @@ import { Button } from "@/src/components/ui/button";import { Bot, Check, Code2 } from "@langfuse/icons";import { EvaluatorSelector } from "./EvaluatorSelector";import { EvalTemplateForm } from "./EvalTemplateForm";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { Card } from "@/src/components/ui/card";import { Skeleton } from "@/src/components/ui/skeleton";import {diff --git a/web/src/features/evals/components/VariableMappingCard.tsx b/web/src/features/evals/components/VariableMappingCard.tsxindex cdd5785771..6bd36db756 100644--- a/web/src/features/evals/components/VariableMappingCard.tsx+++ b/web/src/features/evals/components/VariableMappingCard.tsx@@ -47,7 +47,7 @@ import {import { useFieldArray, type UseFormReturn } from "react-hook-form";import { Input } from "@/src/components/ui/input";import { Switch } from "@/src/components/design-system/Switch/Switch";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import { useEvalConfigMappingData } from "@/src/features/evals/hooks/useEvalConfigMappingData";import { useEffect, useState } from "react";import { Alert } from "@/src/components/design-system/Alert/Alert";@@ -56,7 +56,7 @@ import { useVariableMappingSync } from "@/src/features/evals/hooks/useVariableMaimport { Button } from "@/src/components/ui/button";import Link from "next/link";import { useRouter } from "next/router";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import {type EvalPreviewPointer,buildEvalPreviewNavigationPath,diff --git a/web/src/features/evals/components/default-eval-model-setup.tsx b/web/src/features/evals/components/default-eval-model-setup.tsxindex 1c311ca32a..8fc1587f50 100644--- a/web/src/features/evals/components/default-eval-model-setup.tsx+++ b/web/src/features/evals/components/default-eval-model-setup.tsx@@ -1,11 +1,11 @@/* eslint-disable @repo/no-style-props, @repo/no-abstracted-overlay-trigger, @repo/component-file-structure, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ModelParameters } from "@/src/components/ModelParameters";import { CardContent, Card } from "@/src/components/ui/card";-import { useModelParams } from "@/src/features/playground";+import { useModelParams } from "@/src/features/playground/page/hooks/useModelParams";import { Button } from "@/src/components/ui/button";import { api } from "@/src/utils/api";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import type { ToastOperation } from "@/src/features/notifications/toastAnalytics";import { Skeleton } from "@/src/components/ui/skeleton";import { useEvaluationModel } from "@/src/features/evals/hooks/useEvaluationModel";diff --git a/web/src/features/evals/constants/tableSearchRegistry.clienttest.ts b/web/src/features/evals/constants/tableSearchRegistry.clienttest.tsindex 9062d2e423..3563e8350e 100644--- a/web/src/features/evals/constants/tableSearchRegistry.clienttest.ts+++ b/web/src/features/evals/constants/tableSearchRegistry.clienttest.ts@@ -1,7 +1,8 @@// @vitest-environment nodeimport { describe, expect, it } from "vitest";-import { planCommit, runSearchBarInvariants } from "@/src/features/search-bar";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { runSearchBarInvariants } from "@/src/features/search-bar/lib/searchBarInvariants";import {EVAL_LOGS_FIELD_REGISTRY,diff --git a/web/src/features/evals/constants/tableSearchRegistry.ts b/web/src/features/evals/constants/tableSearchRegistry.tsindex a0c09f4de3..a614ecc144 100644--- a/web/src/features/evals/constants/tableSearchRegistry.ts+++ b/web/src/features/evals/constants/tableSearchRegistry.ts@@ -1,7 +1,7 @@-import type { FilterConfig } from "@/src/features/filters";+import type { FilterConfig } from "@/src/features/filters/lib/filter-config";import { evaluatorFilterConfig } from "@/src/features/filters/config/evaluators-config";import { evalLogFilterConfig } from "@/src/features/filters/config/eval-logs-config";-import { fieldRegistryFromColumns } from "@/src/features/search-bar";+import { fieldRegistryFromColumns } from "@/src/features/search-bar/lib/fields";function facetColumns(config: FilterConfig) {const exposed = new Set(config.facets.map((facet) => facet.column));diff --git a/web/src/features/evals/eval-config-target-options.clienttest.ts b/web/src/features/evals/eval-config-target-options.clienttest.tsindex 15a1ac1024..d4b2cb3139 100644--- a/web/src/features/evals/eval-config-target-options.clienttest.ts+++ b/web/src/features/evals/eval-config-target-options.clienttest.ts@@ -4,7 +4,7 @@ import {EvalTargetObject,LangfuseInternalTraceEnvironment,} from "@langfuse/shared";-import { resolveCheckboxOperator } from "@/src/features/filters";+import { resolveCheckboxOperator } from "@/src/features/filters/hooks/useSidebarFilterState";import { evalConfigFilterColumns } from "@/src/server/api/definitions/evalConfigsTable";import {DEFAULT_OBSERVATION_FILTER,diff --git a/web/src/features/evals/hooks/useEvalCapabilities.ts b/web/src/features/evals/hooks/useEvalCapabilities.tsindex 1eb9cc4093..6ee00d1290 100644--- a/web/src/features/evals/hooks/useEvalCapabilities.ts+++ b/web/src/features/evals/hooks/useEvalCapabilities.ts@@ -1,7 +1,7 @@import { useSession } from "next-auth/react";import { api } from "@/src/utils/api";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useReadPath } from "@/src/features/events";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { useIsCodeEvalEnabled } from "@/src/features/evals/hooks/useIsCodeEvalEnabled";import { useForceV3Experience } from "@/src/features/v4-migration/useForceV3Experience";import { isNewLegacyEvalAllowed } from "@/src/features/evals/utils/legacyEvalGate";diff --git a/web/src/features/evals/hooks/useEvalConfigFilterOptions.ts b/web/src/features/evals/hooks/useEvalConfigFilterOptions.tsindex 13c957b1e8..36cdf57222 100644--- a/web/src/features/evals/hooks/useEvalConfigFilterOptions.ts+++ b/web/src/features/evals/hooks/useEvalConfigFilterOptions.ts@@ -1,4 +1,4 @@-import { sortOptionValues } from "@/src/features/filters";+import { sortOptionValues } from "@/src/features/filters/lib/option-sort";import { api } from "@/src/utils/api";import {type ExperimentEvalOptions,diff --git a/web/src/features/evals/hooks/useEvalConfigMappingData.ts b/web/src/features/evals/hooks/useEvalConfigMappingData.tsindex d215c89fb9..9dc5055e81 100644--- a/web/src/features/evals/hooks/useEvalConfigMappingData.ts+++ b/web/src/features/evals/hooks/useEvalConfigMappingData.ts@@ -7,7 +7,7 @@ import {usePreviewData,} from "@/src/features/evals/hooks/usePreviewData";import { useEffect, useRef } from "react";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { isTraceTargetOnV4 } from "@/src/features/evals/utils/typeHelpers";import {type EvalPreviewPointer,diff --git a/web/src/features/evals/hooks/useEvalPreviewNavigation.ts b/web/src/features/evals/hooks/useEvalPreviewNavigation.tsindex 20ac567f50..eaf89ea02e 100644--- a/web/src/features/evals/hooks/useEvalPreviewNavigation.ts+++ b/web/src/features/evals/hooks/useEvalPreviewNavigation.ts@@ -1,11 +1,12 @@import {detailPageListKeys,+ useFirstDetailPageListEntry,type EventDetailPageListEntry,type ListEntry,type ObservationDetailPageListEntry,type TraceDetailPageListEntry,- useFirstDetailPageListEntry,-} from "@/src/features/navigate-detail-pages";+} from "@/src/features/navigate-detail-pages/DetailPageListsProvider";+import { type NextRouter } from "next/router";import {EvalTargetObject,diff --git a/web/src/features/evals/hooks/useExtractVariables.ts b/web/src/features/evals/hooks/useExtractVariables.tsindex 3ed9a7ba37..4dbd5160de 100644--- a/web/src/features/evals/hooks/useExtractVariables.ts+++ b/web/src/features/evals/hooks/useExtractVariables.ts@@ -1,7 +1,7 @@import { type PreviewData } from "@/src/features/evals/hooks/usePreviewData";import { type VariableMapping } from "@/src/features/evals/utils/evaluator-form-utils";import { api } from "@/src/utils/api";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import {EvalTargetObject,extractValueFromObjectAsString,diff --git a/web/src/features/evals/hooks/usePreviewData.ts b/web/src/features/evals/hooks/usePreviewData.tsindex d27daa8f3c..6c02aaf8a7 100644--- a/web/src/features/evals/hooks/usePreviewData.ts+++ b/web/src/features/evals/hooks/usePreviewData.ts@@ -4,7 +4,7 @@ import {isEventTarget,isExperimentTarget,} from "@/src/features/evals/utils/typeHelpers";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { api, sendAsPostOption, type RouterOutputs } from "@/src/utils/api";import {EvalTargetObject,diff --git a/web/src/features/evals/index.ts b/web/src/features/evals/index.tsdeleted file mode 100644index b5f8961576..0000000000--- a/web/src/features/evals/index.ts+++ /dev/null@@ -1,11 +0,0 @@-export { EvaluatorAssignmentsEditor } from "@/src/features/evals/v2/components/Rules/EvaluatorAssignmentsEditor/EvaluatorAssignmentsEditor";-export { buildSelectedSampleObject } from "@/src/features/evals/v2/fns/evaluatorTesting/buildSelectedSampleObject";-export { managedEvaluatorTemplateService } from "@/src/features/evals/v2/fns/templateGallery/managedEvaluatorTemplateService";-export {- createRuleSetupStore,- isRuleDraftDirty,-} from "@/src/features/evals/v2/stores/createRuleSetupStore";-export type {- RuleDraft,- RuleEvaluatorOption,-} from "@/src/features/evals/v2/types/rules";diff --git a/web/src/features/evals/pages/DefaultEvaluationModelPage.tsx b/web/src/features/evals/pages/DefaultEvaluationModelPage.tsxindex 0560b1b9e4..b92271f077 100644--- a/web/src/features/evals/pages/DefaultEvaluationModelPage.tsx+++ b/web/src/features/evals/pages/DefaultEvaluationModelPage.tsx@@ -1,7 +1,7 @@import Page from "@/src/components/layouts/Page";import { useRouter } from "next/router";-import { useHasProjectAccess } from "@/src/features/rbac";-import { SupportOrUpgradePage } from "@/src/ee/features/billing";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";import { DefaultEvalModelSetup } from "@/src/features/evals/components/default-eval-model-setup";export default function DefaultEvaluationModelPage() {diff --git a/web/src/features/evals/pages/EvaluatorsPage.tsx b/web/src/features/evals/pages/EvaluatorsPage.tsxindex 446ed84c0c..da831eb001 100644--- a/web/src/features/evals/pages/EvaluatorsPage.tsx+++ b/web/src/features/evals/pages/EvaluatorsPage.tsx@@ -1,13 +1,16 @@import Page from "@/src/components/layouts/Page";import { useRouter } from "next/router";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Plus } from "@langfuse/icons";import EvaluatorTable from "@/src/features/evals/components/EvaluatorTable";-import { getEvalsTabs, EVALS_TABS } from "@/src/features/navigation";+import {+ getEvalsTabs,+ EVALS_TABS,+} from "@/src/features/navigation/utils/evals-tabs";import { ActionButton } from "@/src/components/ActionButton";import { api } from "@/src/utils/api";-import { useEntitlementLimit } from "@/src/features/entitlements";-import { SupportOrUpgradePage } from "@/src/ee/features/billing";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";import { EvaluatorsOnboarding } from "@/src/components/onboarding/EvaluatorsOnboarding";import { ManageDefaultEvalModel } from "@/src/features/evals/components/ManageDefaultEvalModel";import { V4MigrationUpdateRequiredBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";diff --git a/web/src/features/evals/pages/NewEvaluatorPage.tsx b/web/src/features/evals/pages/NewEvaluatorPage.tsxindex 05b52811e9..ef2cb66818 100644--- a/web/src/features/evals/pages/NewEvaluatorPage.tsx+++ b/web/src/features/evals/pages/NewEvaluatorPage.tsx@@ -12,7 +12,7 @@ import { useRouter } from "next/router";import { SelectEvaluatorList } from "@/src/features/evals/components/SelectEvaluatorList";import { RunEvaluatorForm } from "@/src/features/evals/components/RunEvaluatorForm";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { getMaintainer } from "@/src/features/evals/utils/typeHelpers";import { MaintainerTooltip } from "@/src/features/evals/components/MaintainerTooltip";import { DefaultEvalModelSetup } from "@/src/features/evals/components/default-eval-model-setup";diff --git a/web/src/features/evals/pages/NewTemplatesPage.tsx b/web/src/features/evals/pages/NewTemplatesPage.tsxindex 05b5f11ded..6498e1f428 100644--- a/web/src/features/evals/pages/NewTemplatesPage.tsx+++ b/web/src/features/evals/pages/NewTemplatesPage.tsx@@ -1,6 +1,6 @@import Page from "@/src/components/layouts/Page";import { EvalTemplateForm } from "@/src/features/evals/components/EvalTemplateForm";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useRouter } from "next/router";export default function NewTemplatesPage() {diff --git a/web/src/features/evals/pages/RemapEvaluatorPage.tsx b/web/src/features/evals/pages/RemapEvaluatorPage.tsxindex 2c236b7bd0..4648700b76 100644--- a/web/src/features/evals/pages/RemapEvaluatorPage.tsx+++ b/web/src/features/evals/pages/RemapEvaluatorPage.tsx@@ -21,8 +21,8 @@ import { useEvalCapabilities } from "@/src/features/evals/hooks/useEvalCapabilitimport {useIsInAppAgentLauncherVisible,useInAppAiAgent,-} from "@/src/features/in-app-agent";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+} from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useEvalUpgradeAssistantPlan } from "@/src/features/v4-migration/useV4UpgradeAssistantSupport";import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { useProjectV4SdkData } from "@/src/features/v4-migration/hooks/useV4MigrationData";@@ -31,7 +31,7 @@ import {DEFAULT_OBSERVATION_FILTER_WHEN_REMAPPING,} from "@/src/features/evals/utils/evaluator-constants";import { buildModernEvaluatorsUrl } from "@/src/features/v4-migration/evaluatorMigrationUrls";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";const V4_DOCS_URL = "https://langfuse.com/docs/v4";const EVAL_MIGRATION_DOCS_URL =diff --git a/web/src/features/evals/pages/TemplatesPage.tsx b/web/src/features/evals/pages/TemplatesPage.tsxindex b7776dbab9..0dfe113ec7 100644--- a/web/src/features/evals/pages/TemplatesPage.tsx+++ b/web/src/features/evals/pages/TemplatesPage.tsx@@ -2,11 +2,14 @@ import Page from "@/src/components/layouts/Page";import { useRouter } from "next/router";import { Button } from "@/src/components/ui/button";import Link from "next/link";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Lock, Plus } from "@langfuse/icons";import EvalsTemplateTable from "@/src/features/evals/components/EvalsTemplateTable";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { getEvalsTabs, EVALS_TABS } from "@/src/features/navigation";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import {+ getEvalsTabs,+ EVALS_TABS,+} from "@/src/features/navigation/utils/evals-tabs";import { ManageDefaultEvalModel } from "@/src/features/evals/components/ManageDefaultEvalModel";import { V4MigrationUpdateRequiredBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";diff --git a/web/src/features/evals/server/defaultEvalModelRouter.ts b/web/src/features/evals/server/defaultEvalModelRouter.tsindex 8683e5f5da..8cb6422ba6 100644--- a/web/src/features/evals/server/defaultEvalModelRouter.ts+++ b/web/src/features/evals/server/defaultEvalModelRouter.ts@@ -1,5 +1,13 @@-import { isPrismaRecordNotFoundError } from "@/src/features/analytics-integrations/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import {+ isPrismaRecordNotFoundError,+ blockEvaluatorsUsingDefaultModel,+ DefaultEvalModelService,+ EvaluatorBlockSource,+ finalizeEvaluatorBlocks,+ invalidateProjectEvalConfigCaches,+ unblockEvaluatorsUsingDefaultModel,+} from "@langfuse/shared/src/server";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,@@ -11,14 +19,6 @@ import {LangfuseNotFoundError,ZodModelConfig,} from "@langfuse/shared";-import {- blockEvaluatorsUsingDefaultModel,- DefaultEvalModelService,- EvaluatorBlockSource,- finalizeEvaluatorBlocks,- invalidateProjectEvalConfigCaches,- unblockEvaluatorsUsingDefaultModel,-} from "@langfuse/shared/src/server";export const defaultEvalModelRouter = createTRPCRouter({fetchDefaultModel: protectedProjectProcedurediff --git a/web/src/features/evals/server/index.ts b/web/src/features/evals/server/index.tsdeleted file mode 100644index e8fdb7a0a3..0000000000--- a/web/src/features/evals/server/index.ts+++ /dev/null@@ -1,8 +0,0 @@-export {- EVAL_TEMPLATE_AUDIT_LOG_RESOURCE_TYPE,- JOB_CONFIGURATION_AUDIT_LOG_RESOURCE_TYPE,-} from "./audit-log-resource-types";-export { EvaluatorService } from "@/src/features/evals/v2/server/evaluators/evaluatorService";-export { EvaluatorDefinitionInputSchema } from "@/src/features/evals/v2/server/evaluators/evaluatorTypes";-export { RuleService } from "@/src/features/evals/v2/server/rules/ruleService";-export { isLegacyEvalTarget } from "@/src/features/evals/utils/typeHelpers";diff --git a/web/src/features/evals/server/router.ts b/web/src/features/evals/server/router.tsindex b5d9fff6bf..d6acc81a36 100644--- a/web/src/features/evals/server/router.ts+++ b/web/src/features/evals/server/router.ts@@ -5,8 +5,8 @@ import {createTRPCRouter,protectedProjectProcedure,} from "@/src/server/api/trpc";-import { throwIfNoProjectAccess } from "@/src/features/rbac";-import { auditLog } from "@/src/features/audit-logs/server";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {DEFAULT_TRACE_JOB_DELAY,deriveEvaluatorDisplayStateFromExecutionCounts,diff --git a/web/src/features/evals/v2/components/EvaluatorGalleryDialog/EvaluatorGalleryDialog.tsx b/web/src/features/evals/v2/components/EvaluatorGalleryDialog/EvaluatorGalleryDialog.tsxindex ed6ca18c71..0fca59e7d8 100644--- a/web/src/features/evals/v2/components/EvaluatorGalleryDialog/EvaluatorGalleryDialog.tsx+++ b/web/src/features/evals/v2/components/EvaluatorGalleryDialog/EvaluatorGalleryDialog.tsx@@ -16,7 +16,7 @@ import {EVALUATOR_GALLERY_ALL_SECTION_KEY,EVALUATOR_GALLERY_RECOMMENDED_SECTION_KEY,} from "@/src/features/evals/v2/constants/evaluatorGallery";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { getEvaluatorCreationAnalyticsProperties } from "@/src/features/evals/v2/fns/evaluators/getEvaluatorCreationAnalyticsProperties";import { getTemplateSelectionAnalyticsProperties } from "@/src/features/evals/v2/fns/templateGallery/getTemplateSelectionAnalyticsProperties";import { api } from "@/src/utils/api";diff --git a/web/src/features/evals/v2/components/Evaluators/EvaluatorActionsCell/EvaluatorActionsCell.tsx b/web/src/features/evals/v2/components/Evaluators/EvaluatorActionsCell/EvaluatorActionsCell.tsxindex 4429ca1b9a..a743af0671 100644--- a/web/src/features/evals/v2/components/Evaluators/EvaluatorActionsCell/EvaluatorActionsCell.tsx+++ b/web/src/features/evals/v2/components/Evaluators/EvaluatorActionsCell/EvaluatorActionsCell.tsx@@ -9,7 +9,7 @@ import {import { Button } from "@/src/components/ui/button";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export function EvaluatorActionsCell({canViewExecutions,diff --git a/web/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton.clienttest.tsx b/web/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton.clienttest.tsxindex 922797d82b..83979d3a97 100644--- a/web/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton.clienttest.tsx+++ b/web/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton.clienttest.tsx@@ -9,7 +9,7 @@ vi.mock("next/router", () => ({useRouter: () => ({ push: routerPush }),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));diff --git a/web/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton.tsx b/web/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton.tsxindex e34deb3889..765dc86b1c 100644--- a/web/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton.tsx+++ b/web/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton.tsx@@ -25,8 +25,8 @@ import {evaluatorAlertsListUrl,evaluatorAlertUrl,} from "@/src/features/evals/v2/fns/evaluators/evaluatorAlertUrl";-import { MonitorSeverityBadge } from "@/src/features/monitors";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { MonitorSeverityBadge } from "@/src/features/monitors/components/MonitorSeverityBadge";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { renderEvaluatorAlertLastFired } from "@/src/features/evals/v2/fns/evaluators/renderEvaluatorAlertLastFired";import { renderEvaluatorAlertTriggerCondition } from "@/src/features/evals/v2/fns/evaluators/renderEvaluatorAlertTriggerCondition";import type { RouterOutputs } from "@/src/utils/api";diff --git a/web/src/features/evals/v2/components/Evaluators/EvaluatorSavedDialogContainer/EvaluatorSavedDialogContainer.tsx b/web/src/features/evals/v2/components/Evaluators/EvaluatorSavedDialogContainer/EvaluatorSavedDialogContainer.tsxindex 625f3d2db2..4afbd66751 100644--- a/web/src/features/evals/v2/components/Evaluators/EvaluatorSavedDialogContainer/EvaluatorSavedDialogContainer.tsx+++ b/web/src/features/evals/v2/components/Evaluators/EvaluatorSavedDialogContainer/EvaluatorSavedDialogContainer.tsx@@ -20,7 +20,7 @@ import { CreateRuleDialog } from "@/src/features/evals/v2/components/Rules/Creatimport { EvaluationRulePicker } from "@/src/features/evals/v2/components/Rules/EvaluationRulePicker/EvaluationRulePicker";import { RuleFilterPills } from "@/src/features/evals/v2/components/Rules/RuleFilterPills/RuleFilterPills";import { useActivationConfirmation } from "@/src/features/evals/v2/hooks/useActivationConfirmation";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api, type RouterOutputs } from "@/src/utils/api";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";import { cn } from "@/src/utils/tailwind";diff --git a/web/src/features/evals/v2/components/Evaluators/JudgeModelConfigurationDialog/JudgeModelConfigurationDialog.tsx b/web/src/features/evals/v2/components/Evaluators/JudgeModelConfigurationDialog/JudgeModelConfigurationDialog.tsxindex 2432e3a87a..0ae7a43a00 100644--- a/web/src/features/evals/v2/components/Evaluators/JudgeModelConfigurationDialog/JudgeModelConfigurationDialog.tsx+++ b/web/src/features/evals/v2/components/Evaluators/JudgeModelConfigurationDialog/JudgeModelConfigurationDialog.tsx@@ -9,7 +9,7 @@ import {DialogHeader,DialogTitle,} from "@/src/components/ui/dialog";-import { useModelParams } from "@/src/features/playground";+import { useModelParams } from "@/src/features/playground/page/hooks/useModelParams";import { getFinalModelParams } from "@/src/utils/getFinalModelParams";import type { ProjectDefaultModelConfig } from "@/src/features/evals/v2/types/ProjectDefaultModelConfig";diff --git a/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.tsx b/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.tsxindex 0379bcfc8d..12ea8b90c3 100644--- a/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.tsx+++ b/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.tsx@@ -10,7 +10,7 @@ import {} from "@uiw/react-codemirror";import { Prec } from "@codemirror/state";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { Switch } from "@/src/components/design-system/Switch/Switch";import { cn } from "@/src/utils/tailwind";import { isValidVariableName, MUSTACHE_REGEX } from "@langfuse/shared";diff --git a/web/src/features/evals/v2/components/Evaluators/Testing/components/RuleSampleObservationSelector/RuleSampleObservationSelector.tsx b/web/src/features/evals/v2/components/Evaluators/Testing/components/RuleSampleObservationSelector/RuleSampleObservationSelector.tsxindex 3d1f242a2e..2d9d143b17 100644--- a/web/src/features/evals/v2/components/Evaluators/Testing/components/RuleSampleObservationSelector/RuleSampleObservationSelector.tsx+++ b/web/src/features/evals/v2/components/Evaluators/Testing/components/RuleSampleObservationSelector/RuleSampleObservationSelector.tsx@@ -1,7 +1,7 @@import { useMemo } from "react";import type { FilterState } from "@langfuse/shared";-import type { FieldRegistry } from "@/src/features/search-bar";+import type { FieldRegistry } from "@/src/features/search-bar/lib/fields";import type { AbsoluteTimeRange } from "@/src/utils/date-range-utils";import { compactNumberFormatter } from "@/src/utils/numbers";import {diff --git a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsxindex ad217ab74f..851823f624 100644--- a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx+++ b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx@@ -26,18 +26,17 @@ import type { LangfuseColumnDef } from "@/src/components/table/types";import { Button } from "@/src/components/ui/button";import { Skeleton } from "@/src/components/ui/skeleton";import useLocalStorage from "@/src/components/useLocalStorage";+import { buildAiContext } from "@/src/features/search-bar/lib/ai-context";import {- buildAiContext,EVENTS_FIELD_REGISTRY,- EventsSearchBarRow,type FieldRegistry,- observedScoreNamesFromOptions,- useEventsSearchBar,-} from "@/src/features/search-bar";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+} from "@/src/features/search-bar/lib/fields";+import { EventsSearchBarRow } from "@/src/features/search-bar/components/EventsSearchBarRow";++import { observedScoreNamesFromOptions } from "@/src/features/search-bar/lib/observed-options";+import { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { api, sendAsPostOption, type RouterOutputs } from "@/src/utils/api";import type { AbsoluteTimeRange } from "@/src/utils/date-range-utils";import { SectionHeader } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SectionHeader/SectionHeader";@@ -53,7 +52,7 @@ import {} from "@/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/hooks/useSampleObservationFilterOptions";import { useReusableRuleFilterPresets } from "@/src/features/evals/v2/hooks/useReusableRuleFilterPresets";import type { EvaluatorFilterExperience } from "@/src/features/evals/v2/types/evaluatorFilterExperience";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export type SampleObservation =RouterOutputs["events"]["all"]["observations"][number];diff --git a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/ObservationFilterBuilder/ObservationFilterBuilder.tsx b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/ObservationFilterBuilder/ObservationFilterBuilder.tsxindex e4ad4fa8bc..f3858e97cd 100644--- a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/ObservationFilterBuilder/ObservationFilterBuilder.tsx+++ b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/ObservationFilterBuilder/ObservationFilterBuilder.tsx@@ -1,6 +1,6 @@import type { ColumnDefinition, FilterState } from "@langfuse/shared";-import { InlineFilterBuilder } from "@/src/features/filters";+import { InlineFilterBuilder } from "@/src/features/filters/components/filter-builder";import { useElementSize } from "@/src/hooks/useElementSize";import { cn } from "@/src/utils/tailwind";diff --git a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/fns/buildSampleQueryFilters.ts b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/fns/buildSampleQueryFilters.tsindex f9484b0252..49f93ccbf5 100644--- a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/fns/buildSampleQueryFilters.ts+++ b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/fns/buildSampleQueryFilters.ts@@ -1,6 +1,6 @@import type { ColumnDefinition, FilterState } from "@langfuse/shared";-import type { ObservedOptions } from "@/src/features/search-bar";+import type { ObservedOptions } from "@/src/features/search-bar/lib/observed-options";import {INTERNAL_EVALUATION_ENVIRONMENTS,INTERNAL_EVALUATION_ENVIRONMENT_FILTERS,diff --git a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/hooks/useSampleObservationFilterOptions.ts b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/hooks/useSampleObservationFilterOptions.tsindex 401dc29f2d..e6ee605cc8 100644--- a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/hooks/useSampleObservationFilterOptions.ts+++ b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/hooks/useSampleObservationFilterOptions.ts@@ -8,13 +8,16 @@ import {type TimeFilter,} from "@langfuse/shared";-import { useEventsFilterOptions } from "@/src/features/events";+import { useEventsFilterOptions } from "@/src/features/events/hooks/useEventsFilterOptions";import {type FieldRegistry,+ withFieldOptions,+} from "@/src/features/search-bar/lib/fields";+import {type ObservedOptions,toObservedOptions,- withFieldOptions,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/lib/observed-options";+import {removeInternalEvaluationEnvironmentColumnOptions,removeInternalEvaluationEnvironmentOptions,diff --git a/web/src/features/evals/v2/components/EvaluatorsEmptyState/EvaluatorsEmptyState.tsx b/web/src/features/evals/v2/components/EvaluatorsEmptyState/EvaluatorsEmptyState.tsxindex 28951d7913..6959f3c67c 100644--- a/web/src/features/evals/v2/components/EvaluatorsEmptyState/EvaluatorsEmptyState.tsx+++ b/web/src/features/evals/v2/components/EvaluatorsEmptyState/EvaluatorsEmptyState.tsx@@ -1,4 +1,4 @@-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { EvaluatorsEmptyStateView } from "./components/EvaluatorsEmptyStateView/EvaluatorsEmptyStateView";import { prepareEvaluatorEmptyState } from "@/src/features/evals/v2/fns/templateGallery/prepareEvaluatorEmptyState";import type { GalleryTemplate } from "@/src/features/evals/v2/types/templateGallery";diff --git a/web/src/features/evals/v2/components/Rules/CreateRuleDialog/components/CreateRuleDialogContent/CreateRuleDialogContent.tsx b/web/src/features/evals/v2/components/Rules/CreateRuleDialog/components/CreateRuleDialogContent/CreateRuleDialogContent.tsxindex b0e9aa0701..76f6b5f0b7 100644--- a/web/src/features/evals/v2/components/Rules/CreateRuleDialog/components/CreateRuleDialogContent/CreateRuleDialogContent.tsx+++ b/web/src/features/evals/v2/components/Rules/CreateRuleDialog/components/CreateRuleDialogContent/CreateRuleDialogContent.tsx@@ -1,5 +1,5 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import type { EvalTargetObject, FilterState } from "@langfuse/shared";import { useRef, useState } from "react";import {@@ -17,11 +17,11 @@ import type {RuleDraft,RuleEvaluatorOption,} from "@/src/features/evals/v2/types/rules";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useProject } from "@/src/features/projects";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useProject } from "@/src/features/projects/hooks";import { prepareNameForSave } from "@/src/features/evals/v2/fns/prepareNameForSave";import { getFilterAnalyticsProperties } from "@/src/features/evals/v2/fns/getFilterAnalyticsProperties";import { resolveInitialRuleFilters } from "./resolveInitialRuleFilters";diff --git a/web/src/features/evals/v2/components/Rules/EditRuleDialog/components/EditRuleDialogContent/EditRuleDialogContent.tsx b/web/src/features/evals/v2/components/Rules/EditRuleDialog/components/EditRuleDialogContent/EditRuleDialogContent.tsxindex 95d4fe7a84..405a633f49 100644--- a/web/src/features/evals/v2/components/Rules/EditRuleDialog/components/EditRuleDialogContent/EditRuleDialogContent.tsx+++ b/web/src/features/evals/v2/components/Rules/EditRuleDialog/components/EditRuleDialogContent/EditRuleDialogContent.tsx@@ -1,5 +1,5 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import {EvalTemplateType,observationVariableMappingList,@@ -12,7 +12,7 @@ import { RuleSetup } from "@/src/features/evals/v2/components/Rules/RuleSetup/Ruimport { createRuleSetupStore } from "@/src/features/evals/v2/stores/createRuleSetupStore";import { prepareModernRuleVariableMapping } from "@/src/features/evals/v2/fns/variableMapping/prepareModernRuleVariableMapping";import type { RuleEvaluatorOption } from "@/src/features/evals/v2/types/rules";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api, type RouterOutputs } from "@/src/utils/api";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";import { getFilterAnalyticsProperties } from "@/src/features/evals/v2/fns/getFilterAnalyticsProperties";diff --git a/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/EvaluatorRuleRelationships.tsx b/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/EvaluatorRuleRelationships.tsxindex 78429cdd0e..64fca24c46 100644--- a/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/EvaluatorRuleRelationships.tsx+++ b/web/src/features/evals/v2/components/Rules/EvaluatorRuleRelationships/EvaluatorRuleRelationships.tsx@@ -1,4 +1,4 @@-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { EvalTargetObject, EvalTemplateType } from "@langfuse/shared";import { Link2, Plus, Unlink } from "@langfuse/icons";import { useRouter } from "next/router";@@ -19,7 +19,7 @@ import { ActivationConfirmationDialog } from "@/src/features/evals/v2/componentsimport { CreateRuleDialog } from "@/src/features/evals/v2/components/Rules/CreateRuleDialog/CreateRuleDialog";import { EvaluationRulePicker } from "@/src/features/evals/v2/components/Rules/EvaluationRulePicker/EvaluationRulePicker";import { useActivationConfirmation } from "@/src/features/evals/v2/hooks/useActivationConfirmation";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";import { prepareModernRuleVariableMapping } from "@/src/features/evals/v2/fns/variableMapping/prepareModernRuleVariableMapping";diff --git a/web/src/features/evals/v2/components/Rules/RuleFilterPills/RuleFilterPills.tsx b/web/src/features/evals/v2/components/Rules/RuleFilterPills/RuleFilterPills.tsxindex 04aea8ad74..17cc35d5b6 100644--- a/web/src/features/evals/v2/components/Rules/RuleFilterPills/RuleFilterPills.tsx+++ b/web/src/features/evals/v2/components/Rules/RuleFilterPills/RuleFilterPills.tsx@@ -10,13 +10,13 @@ import {TooltipTrigger,} from "@/src/components/ui/tooltip";import { RULE_FIELD_REGISTRY } from "@/src/features/evals/v2/constants/ruleSearchRegistry";-import { InlineFilterState } from "@/src/features/filters";+import { InlineFilterState } from "@/src/features/filters/components/filter-builder";import {ComposerSurface,ComposerText,- ComposerTokens,- filterStateToQueryText,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/components/ComposerSurface";+import { ComposerTokens } from "@/src/features/search-bar/components/ComposerTokens";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";export function RuleFilterPills({filter,diff --git a/web/src/features/evals/v2/components/Rules/RulesTable/RulesTable.tsx b/web/src/features/evals/v2/components/Rules/RulesTable/RulesTable.tsxindex 6865736ff9..082c6fa707 100644--- a/web/src/features/evals/v2/components/Rules/RulesTable/RulesTable.tsx+++ b/web/src/features/evals/v2/components/Rules/RulesTable/RulesTable.tsx@@ -36,13 +36,11 @@ import { RuleActiveSwitchCell } from "@/src/features/evals/v2/components/Rules/Rimport { RuleNameCell } from "@/src/features/evals/v2/components/Rules/RulesTable/components/RuleNameCell/RuleNameCell";import { RulesTableToolbar } from "@/src/features/evals/v2/components/Rules/RulesTable/components/RulesTableToolbar/RulesTableToolbar";import { usePaginationState } from "@/src/hooks/usePaginationState";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { TableSelectionManager } from "@/src/features/table";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";import { RuleFilterPills } from "@/src/features/evals/v2/components/Rules/RuleFilterPills/RuleFilterPills";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import type { RuleTableRow } from "@/src/features/evals/v2/types/rules";import {Tooltip,@@ -62,11 +60,10 @@ import {} from "@/src/features/evals/v2/utils/ruleNavigation";import { ruleExecutionsUrl } from "@/src/features/evals/v2/fns/rules/ruleExecutionsUrl";import { TableViewPresetTableName, type OrderByState } from "@langfuse/shared";-import {- omitFilterFacets,- useSidebarFilterState,-} from "@/src/features/filters";-import { TableSearchBar, toObservedOptions } from "@/src/features/search-bar";+import { omitFilterFacets } from "@/src/features/filters/lib/filter-config";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { evaluationRulesListFieldRegistry } from "@/src/features/evals/v2/constants/tableSearchRegistry";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";@@ -76,7 +73,7 @@ import {evaluationRuleTableFilterOptions,} from "@/src/features/evals/v2/constants/tableFilterColumns";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { createUserTableColumn } from "@/src/components/design-system/table/columns/createUserTableColumn";function RelativeDate({ date }: { date: Date }) {diff --git a/web/src/features/evals/v2/components/Rules/RulesTable/components/RuleActiveSwitchCell/RuleActiveSwitchCell.tsx b/web/src/features/evals/v2/components/Rules/RulesTable/components/RuleActiveSwitchCell/RuleActiveSwitchCell.tsxindex 7c61dbc287..ffcda1157d 100644--- a/web/src/features/evals/v2/components/Rules/RulesTable/components/RuleActiveSwitchCell/RuleActiveSwitchCell.tsx+++ b/web/src/features/evals/v2/components/Rules/RulesTable/components/RuleActiveSwitchCell/RuleActiveSwitchCell.tsx@@ -1,6 +1,6 @@import { Switch } from "@/src/components/design-system/Switch/Switch";import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api, type RouterOutputs } from "@/src/utils/api";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";import { isLegacyEvalTarget } from "@/src/features/evals/utils/typeHelpers";diff --git a/web/src/features/evals/v2/components/Rules/RulesTable/components/RulesOverviewSelectionBar/RulesOverviewSelectionBar.tsx b/web/src/features/evals/v2/components/Rules/RulesTable/components/RulesOverviewSelectionBar/RulesOverviewSelectionBar.tsxindex 656dea3bf9..2df92855bb 100644--- a/web/src/features/evals/v2/components/Rules/RulesTable/components/RulesOverviewSelectionBar/RulesOverviewSelectionBar.tsx+++ b/web/src/features/evals/v2/components/Rules/RulesTable/components/RulesOverviewSelectionBar/RulesOverviewSelectionBar.tsx@@ -2,7 +2,7 @@ import { useState } from "react";import { useStore } from "zustand";import { RulesOverviewSelectionBarView } from "@/src/features/evals/v2/components/Rules/RulesTable/components/RulesOverviewSelectionBar/RulesOverviewSelectionBarView";import type { RulesTableStore } from "@/src/features/evals/v2/types/rules";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";import type { FilterState } from "@langfuse/shared";diff --git a/web/src/features/evals/v2/components/VariableMapping/components/EditableVariableMapping/EditableVariableMapping.tsx b/web/src/features/evals/v2/components/VariableMapping/components/EditableVariableMapping/EditableVariableMapping.tsxindex 7a9e3a08e5..b68c5c12c9 100644--- a/web/src/features/evals/v2/components/VariableMapping/components/EditableVariableMapping/EditableVariableMapping.tsx+++ b/web/src/features/evals/v2/components/VariableMapping/components/EditableVariableMapping/EditableVariableMapping.tsx@@ -33,7 +33,7 @@ import {deepParseJsonIterative,experimentTargetEvalVariableColumns,} from "@langfuse/shared";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useEvalOnboardingAnalytics } from "@/src/features/evals/v2/contexts/EvalOnboardingAnalyticsProvider";const TOOL_CALLS_COLUMN_ID = "toolCalls";diff --git a/web/src/features/evals/v2/constants/evaluatorSearchRegistry.ts b/web/src/features/evals/v2/constants/evaluatorSearchRegistry.tsindex 6304e04b9e..222623a0f9 100644--- a/web/src/features/evals/v2/constants/evaluatorSearchRegistry.ts+++ b/web/src/features/evals/v2/constants/evaluatorSearchRegistry.ts@@ -4,7 +4,7 @@ import {EVENTS_FIELD_REGISTRY,extendFieldRegistryWithColumns,type FieldRegistry,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/lib/fields";const withDatasetNameAiContext = (registry: FieldRegistry,diff --git a/web/src/features/evals/v2/constants/ruleSearchRegistry.ts b/web/src/features/evals/v2/constants/ruleSearchRegistry.tsindex ebfc0594df..a3129a8b0c 100644--- a/web/src/features/evals/v2/constants/ruleSearchRegistry.ts+++ b/web/src/features/evals/v2/constants/ruleSearchRegistry.ts@@ -1,6 +1,6 @@import { eventsEvalFilterColumns } from "@langfuse/shared";-import { fieldRegistryFromColumns } from "@/src/features/search-bar";+import { fieldRegistryFromColumns } from "@/src/features/search-bar/lib/fields";/*** Derived from the same columns the rule service validates. The overlay onlydiff --git a/web/src/features/evals/v2/constants/tableFilterColumns.ts b/web/src/features/evals/v2/constants/tableFilterColumns.tsindex 7a39bb9f1e..40abce6476 100644--- a/web/src/features/evals/v2/constants/tableFilterColumns.ts+++ b/web/src/features/evals/v2/constants/tableFilterColumns.ts@@ -1,5 +1,5 @@import { EvalTemplateType, type ColumnDefinition } from "@langfuse/shared";-import type { FilterConfig } from "@/src/features/filters";+import type { FilterConfig } from "@/src/features/filters/lib/filter-config";const evaluatorStatusOptions = [{ value: "ACTIVE", displayValue: "Active" },diff --git a/web/src/features/evals/v2/constants/tableSearchRegistry.clienttest.ts b/web/src/features/evals/v2/constants/tableSearchRegistry.clienttest.tsindex 3c06a5e2e9..152887fb4c 100644--- a/web/src/features/evals/v2/constants/tableSearchRegistry.clienttest.ts+++ b/web/src/features/evals/v2/constants/tableSearchRegistry.clienttest.ts@@ -2,12 +2,10 @@import { describe, expect, it } from "vitest";import type { FilterState } from "@langfuse/shared";-import {- planCommit,- filterStateToQueryText,- runSearchBarInvariants,- validateQuery,-} from "@/src/features/search-bar";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";+import { runSearchBarInvariants } from "@/src/features/search-bar/lib/searchBarInvariants";+import { validateQuery } from "@/src/features/search-bar/lib/validate";import { evaluationRuleTableFilterConfig } from "./tableFilterColumns";import {diff --git a/web/src/features/evals/v2/constants/tableSearchRegistry.ts b/web/src/features/evals/v2/constants/tableSearchRegistry.tsindex cc536c3c13..bbe02ddc6e 100644--- a/web/src/features/evals/v2/constants/tableSearchRegistry.ts+++ b/web/src/features/evals/v2/constants/tableSearchRegistry.ts@@ -1,9 +1,9 @@-import type { FilterConfig } from "@/src/features/filters";+import type { FilterConfig } from "@/src/features/filters/lib/filter-config";import type { FilterState } from "@langfuse/shared";import {fieldRegistryFromColumns,withFieldOptions,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/lib/fields";import {evaluatorTableFilterConfig,evaluatorTableFilterOptions,diff --git a/web/src/features/evals/v2/hooks/useEvaluatorAlerts.ts b/web/src/features/evals/v2/hooks/useEvaluatorAlerts.tsindex 0016e46ebd..8df65e9578 100644--- a/web/src/features/evals/v2/hooks/useEvaluatorAlerts.ts+++ b/web/src/features/evals/v2/hooks/useEvaluatorAlerts.ts@@ -1,5 +1,5 @@-import { useEntitlementLimit } from "@/src/features/entitlements";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";/** Owns evaluator alert permissions, linked-alert loading, and creation limits. */diff --git a/web/src/features/evals/v2/hooks/useProjectDefaultModel.ts b/web/src/features/evals/v2/hooks/useProjectDefaultModel.tsindex 8d80e45d2e..d41f0b50f3 100644--- a/web/src/features/evals/v2/hooks/useProjectDefaultModel.ts+++ b/web/src/features/evals/v2/hooks/useProjectDefaultModel.ts@@ -1,12 +1,12 @@-import { showSuccessToast } from "@/src/features/notifications";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useState } from "react";import { env } from "@/src/env.mjs";import { getJudgeModelProviderAdapters } from "@/src/features/evals/v2/judgeModel";-import { getConnectionAvailableModels } from "@/src/features/llm-api-key";+import { getConnectionAvailableModels } from "@/src/features/llm-api-key/availableModels";import type { ProjectDefaultModelConfig } from "@/src/features/evals/v2/types/ProjectDefaultModelConfig";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";diff --git a/web/src/features/evals/v2/hooks/useReusableRuleFilterPresets.clienttest.ts b/web/src/features/evals/v2/hooks/useReusableRuleFilterPresets.clienttest.tsindex 944a39a10a..fb550b7a77 100644--- a/web/src/features/evals/v2/hooks/useReusableRuleFilterPresets.clienttest.ts+++ b/web/src/features/evals/v2/hooks/useReusableRuleFilterPresets.clienttest.ts@@ -9,7 +9,7 @@ import { prepareReusableRuleFilterPresets } from "@/src/features/evals/v2/hooks/import {EVENTS_FIELD_REGISTRY,withFieldOptions,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/lib/fields";const reusableFilters = [{diff --git a/web/src/features/evals/v2/hooks/useReusableRuleFilterPresets.ts b/web/src/features/evals/v2/hooks/useReusableRuleFilterPresets.tsindex 8009fb97e1..f6b0158561 100644--- a/web/src/features/evals/v2/hooks/useReusableRuleFilterPresets.ts+++ b/web/src/features/evals/v2/hooks/useReusableRuleFilterPresets.ts@@ -3,12 +3,10 @@ import { useMemo } from "react";import type { FilterState } from "@langfuse/shared";import { RULE_FIELD_REGISTRY } from "@/src/features/evals/v2/constants/ruleSearchRegistry";-import {- type FieldRegistry,- filterStateToQueryText,- type QueryPresetSection,- validateQuery,-} from "@/src/features/search-bar";+import type { FieldRegistry } from "@/src/features/search-bar/lib/fields";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";+import type { QueryPresetSection } from "@/src/features/search-bar/lib/completions";+import { validateQuery } from "@/src/features/search-bar/lib/validate";import { api, type RouterOutputs } from "@/src/utils/api";const SECTION_TITLE = "Reuse rule filters";diff --git a/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx b/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsxindex e279e05570..3a60f73c4a 100644--- a/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx+++ b/web/src/features/evals/v2/pages/EvaluatorSetupPage.tsx@@ -1,5 +1,6 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { useEffect, useMemo, useRef, useState } from "react";import { useRouter } from "next/router";import { TRPCClientError } from "@trpc/client";@@ -37,8 +38,8 @@ import type { NormalizedEvaluatorDefinition } from "../server/evaluators/evaluatimport { api } from "@/src/utils/api";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { detailPageListKeys } from "@/src/features/navigate-detail-pages";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { detailPageListKeys } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { TableHeaderControls } from "@/src/components/table/TableHeaderControls";import { useTableDateRange } from "@/src/hooks/useTableDateRange";import { toAbsoluteTimeRange } from "@/src/utils/date-range-utils";@@ -54,12 +55,12 @@ import { safeRandomUUID } from "@/src/utils/safe-random-uuid";import { EvaluatorSavedDialogContainer } from "@/src/features/evals/v2/components/Evaluators/EvaluatorSavedDialogContainer/EvaluatorSavedDialogContainer";import { EVALUATOR_FILTER_EXPERIENCE_STORAGE_KEY } from "@/src/features/evals/v2/constants/evaluatorFilterExperience";import type { EvaluatorFilterExperience } from "@/src/features/evals/v2/types/evaluatorFilterExperience";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useProject } from "@/src/features/projects";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useProject } from "@/src/features/projects/hooks";import { EvaluatorBlockedBanner } from "@/src/features/evals/v2/components/Evaluators/EvaluatorBlockedBanner/EvaluatorBlockedBanner";import { useIsMobile } from "@/src/hooks/use-mobile";import { prepareEvaluatorMetadataForSave } from "@/src/features/evals/v2/fns/prepareEvaluatorMetadataForSave";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useEvaluatorAlerts } from "@/src/features/evals/v2/hooks/useEvaluatorAlerts";import { useCodeEvalSourceValidation } from "@/src/features/evals/hooks/useCodeEvalSourceValidation";import { EvaluatorAlertButton } from "@/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton";diff --git a/web/src/features/evals/v2/pages/EvaluatorsPage.tsx b/web/src/features/evals/v2/pages/EvaluatorsPage.tsxindex c04a2a1af6..302965864c 100644--- a/web/src/features/evals/v2/pages/EvaluatorsPage.tsx+++ b/web/src/features/evals/v2/pages/EvaluatorsPage.tsx@@ -1,5 +1,5 @@/* eslint-disable no-nested-ternary, react/no-unstable-nested-components */-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { formatDistanceToNowStrict } from "date-fns";import {type OrderByState,@@ -35,17 +35,16 @@ import { EvaluatorGalleryDialog } from "../components/EvaluatorGalleryDialog/Evaimport { EvaluatorStatusBadge } from "../components/Evaluators/EvaluatorStatusBadge/EvaluatorStatusBadge";import { EvaluatorTypeBadge } from "../components/Evaluators/EvaluatorTypeBadge/EvaluatorTypeBadge";import { OverviewSelectionBar } from "@/src/components/table/OverviewSelectionBar/OverviewSelectionBar";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";-import { useHasProjectAccess } from "@/src/features/rbac";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useEvaluatorAlerts } from "@/src/features/evals/v2/hooks/useEvaluatorAlerts";-import { TableSelectionManager } from "@/src/features/table";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";import { usePaginationState } from "@/src/hooks/usePaginationState";-import { useSidebarFilterState } from "@/src/features/filters";-import { TableSearchBar, toObservedOptions } from "@/src/features/search-bar";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { EVALUATORS_LIST_FIELD_REGISTRY } from "../constants/tableSearchRegistry";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";@@ -60,7 +59,10 @@ import {evaluatorExecutionsUrl,evaluatorScoresUrl,} from "../fns/evaluators/evaluatorScoresUrl";-import { EVALS_V2_TABS, getEvalsV2Tabs } from "@/src/features/navigation";+import {+ EVALS_V2_TABS,+ getEvalsV2Tabs,+} from "@/src/features/navigation/utils/evals-v2-tabs";import { DefaultModelChangeConfirmationDialog } from "../components/Evaluators/ProjectDefaultModel/DefaultModelChangeConfirmationDialog";import { useProjectDefaultModel } from "@/src/features/evals/v2/hooks/useProjectDefaultModel";import {@@ -76,7 +78,7 @@ import {import type { GalleryTemplate } from "../types/templateGallery";import { V4MigrationUpdateRequiredBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { createUserTableColumn } from "@/src/components/design-system/table/columns/createUserTableColumn";import { EvaluatorAlertButton } from "@/src/features/evals/v2/components/Evaluators/EvaluatorAlertButton/EvaluatorAlertButton";diff --git a/web/src/features/evals/v2/pages/RulesPage.tsx b/web/src/features/evals/v2/pages/RulesPage.tsxindex c8c995dd29..efbda376c3 100644--- a/web/src/features/evals/v2/pages/RulesPage.tsx+++ b/web/src/features/evals/v2/pages/RulesPage.tsx@@ -3,11 +3,14 @@ import { Plus } from "@langfuse/icons";import { useRouter } from "next/router";import Page from "@/src/components/layouts/Page";import { Button } from "@/src/components/ui/button";-import { SupportOrUpgradePage } from "@/src/ee/features/billing";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";import { CreateRuleDialog } from "@/src/features/evals/v2/components/Rules/CreateRuleDialog/CreateRuleDialog";import { RulesTable } from "@/src/features/evals/v2/components/Rules/RulesTable/RulesTable";-import { useHasProjectAccess } from "@/src/features/rbac";-import { EVALS_V2_TABS, getEvalsV2Tabs } from "@/src/features/navigation";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import {+ EVALS_V2_TABS,+ getEvalsV2Tabs,+} from "@/src/features/navigation/utils/evals-v2-tabs";import { V4MigrationUpdateRequiredBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";export function RulesPage() {diff --git a/web/src/features/evals/v2/server/evaluators/evaluatorRouter.ts b/web/src/features/evals/v2/server/evaluators/evaluatorRouter.tsindex 074e94bd1a..ca08229312 100644--- a/web/src/features/evals/v2/server/evaluators/evaluatorRouter.ts+++ b/web/src/features/evals/v2/server/evaluators/evaluatorRouter.ts@@ -1,5 +1,8 @@-import { auditLog } from "@/src/features/audit-logs/server";-import { hasProjectAccess, throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import {+ hasProjectAccess,+ throwIfNoProjectAccess,+} from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/evals/v2/server/evaluators/evaluatorService.ts b/web/src/features/evals/v2/server/evaluators/evaluatorService.tsindex 872a2aa68e..7b71d94dd7 100644--- a/web/src/features/evals/v2/server/evaluators/evaluatorService.ts+++ b/web/src/features/evals/v2/server/evaluators/evaluatorService.ts@@ -25,7 +25,7 @@ import {invalidateProjectEvalConfigCaches,logger,} from "@langfuse/shared/src/server";-import { resolveLangfuseAiFeatureAvailability } from "@/src/features/ai-features/server";+import { resolveLangfuseAiFeatureAvailability } from "@/src/features/ai-features/server/availability";import { getEvaluatorDefinitionPreflightError } from "@/src/features/evals/server/evaluator-preflight";import {type CreateEvaluatorInput,diff --git a/web/src/features/evals/v2/server/rules/ruleRouter.ts b/web/src/features/evals/v2/server/rules/ruleRouter.tsindex 1091fbc659..053728e7e4 100644--- a/web/src/features/evals/v2/server/rules/ruleRouter.ts+++ b/web/src/features/evals/v2/server/rules/ruleRouter.ts@@ -1,6 +1,6 @@-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { JOB_CONFIGURATION_AUDIT_LOG_RESOURCE_TYPE } from "@/src/features/evals/server/audit-log-resource-types";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/evals/v2/server/rules/ruleService.ts b/web/src/features/evals/v2/server/rules/ruleService.tsindex f65f3aa2e5..619e3763c0 100644--- a/web/src/features/evals/v2/server/rules/ruleService.ts+++ b/web/src/features/evals/v2/server/rules/ruleService.ts@@ -24,7 +24,7 @@ import {logger,getTotalCostByRule,} from "@langfuse/shared/src/server";-import { resolveLangfuseAiFeatureAvailability } from "@/src/features/ai-features/server";+import { resolveLangfuseAiFeatureAvailability } from "@/src/features/ai-features/server/availability";import type {CreateOrAttachFromEvaluatorFiltersInput,CreateRuleInput,diff --git a/web/src/features/evals/v2/utils/datasetNameFilter.clienttest.ts b/web/src/features/evals/v2/utils/datasetNameFilter.clienttest.tsindex 9253bda641..4676077bca 100644--- a/web/src/features/evals/v2/utils/datasetNameFilter.clienttest.ts+++ b/web/src/features/evals/v2/utils/datasetNameFilter.clienttest.ts@@ -7,10 +7,11 @@ import {} from "@/src/features/evals/v2/constants/evaluatorSearchRegistry";import {type FieldRegistry,- filterStateToQueryText,- planCommit,withFieldOptions,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/lib/fields";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { addDatasetNameObservedOptions } from "./datasetNameFilter";const datasets = [diff --git a/web/src/features/evals/v2/utils/datasetNameFilter.ts b/web/src/features/evals/v2/utils/datasetNameFilter.tsindex 8f35207866..b79caf038d 100644--- a/web/src/features/evals/v2/utils/datasetNameFilter.ts+++ b/web/src/features/evals/v2/utils/datasetNameFilter.ts@@ -1,6 +1,6 @@import type { ColumnDefinition } from "@langfuse/shared";-import type { ObservedOptions } from "@/src/features/search-bar";+import type { ObservedOptions } from "@/src/features/search-bar/lib/observed-options";export type DatasetFilterOption = {id: string;diff --git a/web/src/features/events/EventsPage.tsx b/web/src/features/events/EventsPage.tsxindex 2ce1d1d0c5..1c50aea222 100644--- a/web/src/features/events/EventsPage.tsx+++ b/web/src/features/events/EventsPage.tsx@@ -4,8 +4,11 @@ import ObservationsEventsTable from "@/src/features/events/components/EventsTablimport Page from "@/src/components/layouts/Page";import { api } from "@/src/utils/api";import { TracesOnboarding } from "@/src/components/onboarding/TracesOnboarding";-import { getTracingTabs, TRACING_TABS } from "@/src/features/navigation";-import { useQueryProject } from "@/src/features/projects";+import {+ getTracingTabs,+ TRACING_TABS,+} from "@/src/features/navigation/utils/tracing-tabs";+import { useQueryProject } from "@/src/features/projects/hooks";export default function EventsPage() {const router = useRouter();diff --git a/web/src/features/events/actions/setReadPath.ts b/web/src/features/events/actions/setReadPath.tsindex 5dcee1957f..87233bf2e8 100644--- a/web/src/features/events/actions/setReadPath.ts+++ b/web/src/features/events/actions/setReadPath.ts@@ -2,8 +2,8 @@ import posthog from "posthog-js";import { type ResolvedReadPath } from "@/src/features/events/hooks/useReadPath";import { readPathToggleStore } from "@/src/features/events/stores/readPathToggleStore";-import { showErrorToast } from "@/src/features/notifications";-import { V4_BETA_ENABLED_POSTHOG_PROPERTY } from "@/src/features/posthog-analytics";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { V4_BETA_ENABLED_POSTHOG_PROPERTY } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { setV4BetaEnabledSentryTag } from "@/src/utils/sentryV4BetaTag";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/events/components/CategoryPresetChips.tsx b/web/src/features/events/components/CategoryPresetChips.tsxindex a20498a2b9..dfe4390495 100644--- a/web/src/features/events/components/CategoryPresetChips.tsx+++ b/web/src/features/events/components/CategoryPresetChips.tsx@@ -23,7 +23,7 @@ import {} from "@/src/components/ui/popover";import { cn } from "@/src/utils/tailwind";import { useViewData } from "@/src/components/table/table-view-presets/hooks/useViewData";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";const CATEGORY_ICONS: Record<SystemTableViewPresetCategory, IconComponent> = {[SystemTableViewPresetCategory.SlowCalls]: Timer,diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex 985cb18313..075746eefe 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -1,16 +1,16 @@/* eslint-disable no-nested-ternary, @repo/component-file-structure, react/no-unstable-nested-components */import { eventsSearchRegistry } from "../config/eventsSearchRegistry";+import { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";+import { buildAiContext } from "@/src/features/search-bar/lib/ai-context";+import { EventsSearchBarRow } from "@/src/features/search-bar/components/EventsSearchBarRow";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";import {- useEventsSearchBar,- buildAiContext,- EventsSearchBarRow,- filterStateToQueryText,observedScoreNamesFromOptions,toObservedOptions,- useSearchBarEnabled,withMetadataPathOptions,- useFullTextSearch,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/lib/observed-options";+import { useSearchBarEnabled } from "@/src/features/search-bar/hooks/useSearchBarEnabled";+import { useFullTextSearch } from "@/src/features/search-bar/hooks/useFullTextSearch";import { EmptyValue } from "@/src/components/design-system/table/components/EmptyValue/EmptyValue";import { DataTable } from "@/src/components/table/data-table";@@ -24,12 +24,13 @@ import { ResizableFilterLayout } from "@/src/components/table/resizable-filter-limport { useEffect, useMemo, useState, useRef, useCallback } from "react";import { startOfMinute } from "date-fns";import { usePaginationState } from "@/src/hooks/usePaginationState";+import { buildSidebarFilterSessionContextId } from "@/src/features/filters/lib/persistedSidebarFilterQuery";import {- buildSidebarFilterSessionContextId,useSidebarFilterPresentation,useSidebarFilterStateCore,type UseSidebarFilterStateOptions,-} from "@/src/features/filters";+} from "@/src/features/filters/hooks/useSidebarFilterState";+import {getEventsColumnName,getObservationEventsFilterConfig,@@ -79,7 +80,7 @@ import {formatObservationCost,isObservationCostDisplayable,} from "@/src/utils/observationCost";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import {customRowHeightMenu,getRowHeightIOCharLimit,@@ -102,35 +103,32 @@ import { DataTableRefreshButton } from "@/src/components/table/DataTableRefreshBimport { MobileFiltersSheet } from "@/src/features/events/components/MobileFiltersSheet";import { useIsMobile } from "@/src/hooks/use-mobile";import { usePeekTableState } from "@/src/components/table/peek/contexts/PeekTableStateProvider";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";-import { useHasProjectAccess } from "@/src/features/rbac";-import { BreakdownTooltip } from "@/src/features/traces";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { BreakdownTooltip } from "@/src/features/traces/components/BreakdownTooltip";import { InfoIcon, LightbulbIcon } from "@langfuse/icons";-import { ProvidedModelNameCell } from "@/src/features/models";+import { ProvidedModelNameCell } from "@/src/features/models/components/ProvidedModelNameCell";import { type RowSelectionState } from "@tanstack/react-table";import { TablePeekViewObservationDetail } from "@/src/components/table/peek/TablePeekViewObservationDetail";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";import {detailPageListKeys,useDetailPageLists,-} from "@/src/features/navigate-detail-pages";+} from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import {demoteViewOnUserFilterEdit,type ExplicitFilterStateChange,} from "@/src/features/events/lib/demoteViewOnUserFilterEdit";-import {- TableSelectionManager,- useSelectAll,- TableActionMenu,- type TableAction,-} from "@/src/features/table";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";+import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";+import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";+import type { TableAction } from "@/src/features/table/types";import { type DataTablePeekViewProps } from "@/src/components/table/peek";-import { scoreFilters, useScoreColumns } from "@/src/features/scores";+import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";import { useEventsTableData } from "@/src/features/events/hooks/useEventsTableData";import {useAppRootDefault,@@ -155,17 +153,16 @@ import {} from "@/src/components/table/utils/refresh-intervals";import useSessionStorage from "@/src/components/useSessionStorage";import { api } from "@/src/utils/api";-import {- RunEvaluationDialog,- AddObservationsToDatasetDialog,-} from "@/src/features/batch-actions";-import { useHasEntitlement } from "@/src/features/entitlements";-import { showSuccessToast } from "@/src/features/notifications";+import { RunEvaluationDialog } from "@/src/features/batch-actions/components/RunEvaluationDialog/index";+import { AddObservationsToDatasetDialog } from "@/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { MobileFullTextSearch } from "@/src/features/events/components/MobileFullTextSearch";import { CategoryPresetChips } from "@/src/features/events/components/CategoryPresetChips";import { TableViewPresetsDrawer } from "@/src/components/table/table-view-presets/components/data-table-view-presets-drawer";import { EventsChartView } from "@/src/features/chart-view/EventsChartView";-import { ViewModeToggle, useChartViewState } from "@/src/features/chart-view";+import { ViewModeToggle } from "@/src/features/chart-view/components/ViewModeToggle";+import { useChartViewState } from "@/src/features/chart-view/lib/useChartViewState";import { EventsOutlierStrip } from "@/src/features/events/components/outlier-strip/EventsOutlierStrip";import {chartFacetExclusionReason,@@ -178,7 +175,7 @@ import {useObservedMetadataPaths,useObservedMetadataRecorder,} from "@/src/hooks/useObservedMetadata";-import { AddTracesToAnnotationQueueDialogController } from "@/src/features/annotation-queues";+import { AddTracesToAnnotationQueueDialogController } from "@/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController";export type EventsTableRow = {// Identity fieldsdiff --git a/web/src/features/events/components/MobileFullTextSearch.tsx b/web/src/features/events/components/MobileFullTextSearch.tsxindex cc40aa81ca..54708d9b34 100644--- a/web/src/features/events/components/MobileFullTextSearch.tsx+++ b/web/src/features/events/components/MobileFullTextSearch.tsx@@ -3,7 +3,7 @@import { useState } from "react";import { SearchInput } from "@/src/components/design-system/SearchInput/SearchInput";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";/*** Full-text search input for the mobile Filters sheet, used when the grammardiff --git a/web/src/features/events/components/index.ts b/web/src/features/events/components/index.tsdeleted file mode 100644index 45cb6542ee..0000000000--- a/web/src/features/events/components/index.ts+++ /dev/null@@ -1 +0,0 @@-export { default as ObservationsEventsTable } from "./EventsTable";diff --git a/web/src/features/events/components/outlier-strip/EventsOutlierStrip.tsx b/web/src/features/events/components/outlier-strip/EventsOutlierStrip.tsxindex 931581309c..c9838c4456 100644--- a/web/src/features/events/components/outlier-strip/EventsOutlierStrip.tsx+++ b/web/src/features/events/components/outlier-strip/EventsOutlierStrip.tsx@@ -19,7 +19,7 @@ import {DropdownMenuItem,} from "@/src/components/ui/dropdown-menu";import { toChartFilters } from "@/src/features/chart-view/lib/chartFilterCompatibility";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {estimateYLabelWidthPx,OutlierBarStrip,diff --git a/web/src/features/events/config/eventsSearchRegistry.clienttest.ts b/web/src/features/events/config/eventsSearchRegistry.clienttest.tsindex 5395b72ec4..e21b1e54cb 100644--- a/web/src/features/events/config/eventsSearchRegistry.clienttest.ts+++ b/web/src/features/events/config/eventsSearchRegistry.clienttest.ts@@ -2,12 +2,10 @@import { describe, expect, it } from "vitest";import type { FilterState } from "@langfuse/shared";-import {- EVENTS_FIELD_REGISTRY,- planCommit,- filterStateToQueryText,- runSearchBarInvariants,-} from "@/src/features/search-bar";+import { EVENTS_FIELD_REGISTRY } from "@/src/features/search-bar/lib/fields";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";+import { runSearchBarInvariants } from "@/src/features/search-bar/lib/searchBarInvariants";import { eventsSearchRegistry } from "./eventsSearchRegistry";diff --git a/web/src/features/events/config/eventsSearchRegistry.ts b/web/src/features/events/config/eventsSearchRegistry.tsindex cf351404cb..8a4da76464 100644--- a/web/src/features/events/config/eventsSearchRegistry.ts+++ b/web/src/features/events/config/eventsSearchRegistry.ts@@ -1,7 +1,7 @@import {createFieldRegistry,EVENTS_FIELD_REGISTRY,-} from "@/src/features/search-bar";+} from "@/src/features/search-bar/lib/fields";export function eventsSearchRegistry(omittedColumns: readonly string[],diff --git a/web/src/features/events/config/filter-config.clienttest.ts b/web/src/features/events/config/filter-config.clienttest.tsindex 6b0d786793..facb752071 100644--- a/web/src/features/events/config/filter-config.clienttest.ts+++ b/web/src/features/events/config/filter-config.clienttest.ts@@ -5,11 +5,9 @@ import {observationsTableCols,tracesTableCols,} from "@langfuse/shared";-import {- normalizeFilterColumnNames,- observationFilterConfig,- traceFilterConfig,-} from "@/src/features/filters";+import { normalizeFilterColumnNames } from "@/src/features/filters/lib/filter-transform";+import { observationFilterConfig } from "@/src/features/filters/config/observations-config";+import { traceFilterConfig } from "@/src/features/filters/config/traces-config";import {getEventsColumnName,observationEventsFilterConfig,diff --git a/web/src/features/events/hooks/useAppRootDefault.ts b/web/src/features/events/hooks/useAppRootDefault.tsindex 18ad375d91..20ca90b010 100644--- a/web/src/features/events/hooks/useAppRootDefault.ts+++ b/web/src/features/events/hooks/useAppRootDefault.ts@@ -19,11 +19,9 @@ import {useBrowserStorageValue,writeStorage,} from "@/src/features/events/lib/appRootDefaultStorage";-import {- getSdkVersionCapability,- useProjectSdkVersionInfo,- clearProjectSdkVersionInfo,-} from "@/src/features/sdk-version";+import { getSdkVersionCapability } from "@/src/features/sdk-version/lib/sdkVersionCapabilities";+import { useProjectSdkVersionInfo } from "@/src/features/sdk-version/hooks/useProjectSdkVersionInfo";+import { clearProjectSdkVersionInfo } from "@/src/features/sdk-version/lib/sdkVersionStorage";export function useAppRootDefault(params: {enabled: boolean;diff --git a/web/src/features/events/hooks/useEventsFilterOptions.ts b/web/src/features/events/hooks/useEventsFilterOptions.tsindex 91b2332ae7..207b2f93f4 100644--- a/web/src/features/events/hooks/useEventsFilterOptions.ts+++ b/web/src/features/events/hooks/useEventsFilterOptions.ts@@ -5,7 +5,7 @@ import {planEventFacetQueries,splitFacetFilter,} from "@/src/features/events/lib/facet-query-plan";-import { sortOptionValues } from "@/src/features/filters";+import { sortOptionValues } from "@/src/features/filters/lib/option-sort";import { tablePlaceholderOptions } from "@/src/components/table/utils/tablePlaceholder";type EventFilterOptionColumnsInput =diff --git a/web/src/features/events/hooks/useEventsTableData.clienttest.tsx b/web/src/features/events/hooks/useEventsTableData.clienttest.tsxindex 77d2013dd0..d46e4f0085 100644--- a/web/src/features/events/hooks/useEventsTableData.clienttest.tsx+++ b/web/src/features/events/hooks/useEventsTableData.clienttest.tsx@@ -9,7 +9,7 @@ import { type ReactNode } from "react";import { type TableDataScope } from "@/src/components/table/utils/tablePlaceholder";import { useEventsTableData } from "./useEventsTableData";-vi.mock("@/src/features/notifications", () => ({+vi.mock("@/src/features/notifications/showSuccessToast", () => ({showSuccessToast: vi.fn(),}));diff --git a/web/src/features/events/hooks/useEventsTableData.ts b/web/src/features/events/hooks/useEventsTableData.tsindex b5765368f9..1c5ba901ad 100644--- a/web/src/features/events/hooks/useEventsTableData.ts+++ b/web/src/features/events/hooks/useEventsTableData.ts@@ -7,8 +7,8 @@ import {type ScoreAggregate,} from "@langfuse/shared";import { type FullEventsObservations } from "@langfuse/shared/src/server";-import { showSuccessToast } from "@/src/features/notifications";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { joinTableCoreAndMetrics } from "@/src/components/table/utils/joinTableCoreAndMetrics";import { usePendingRowIds } from "@/src/components/table/hooks/usePendingRowIds";import {diff --git a/web/src/features/events/hooks/useEventsTableSearch.clienttest.tsx b/web/src/features/events/hooks/useEventsTableSearch.clienttest.tsxindex 3ea5723aec..7c8bc174aa 100644--- a/web/src/features/events/hooks/useEventsTableSearch.clienttest.tsx+++ b/web/src/features/events/hooks/useEventsTableSearch.clienttest.tsx@@ -2,7 +2,7 @@ import { act, renderHook } from "@testing-library/react";import { describe, expect, it, vi } from "vitest";import type { TracingSearchType } from "@langfuse/shared";import { eventsSearchRegistry } from "../config/eventsSearchRegistry";-import { useEventsSearchBar } from "@/src/features/search-bar";+import { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";describe("embedded events search scopes", () => {it.each<TracingSearchType[]>([diff --git a/web/src/features/events/hooks/useMetadataValueOptions.ts b/web/src/features/events/hooks/useMetadataValueOptions.tsindex 166179ff81..a9a25c0e94 100644--- a/web/src/features/events/hooks/useMetadataValueOptions.ts+++ b/web/src/features/events/hooks/useMetadataValueOptions.ts@@ -7,7 +7,7 @@ import {} from "@langfuse/shared";import { api, type RouterOutputs } from "@/src/utils/api";-import { normalizeSingleValueOptions } from "@/src/features/filters";+import { normalizeSingleValueOptions } from "@/src/features/filters/lib/filter-transform";/** metadataValueQueryOptions is the shared react-query config for each per-key metadata-value query. */const metadataValueQueryOptions = {diff --git a/web/src/features/events/hooks/useV4PreviewToggle.ts b/web/src/features/events/hooks/useV4PreviewToggle.tsindex df73dfada5..90b6ba04cf 100644--- a/web/src/features/events/hooks/useV4PreviewToggle.ts+++ b/web/src/features/events/hooks/useV4PreviewToggle.ts@@ -13,7 +13,7 @@ import {singleRunToExperimentsUrl,toExperimentsResultsUrl,} from "@/src/features/experiments/utils/experimentUrlTranslation";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";function asSingleValue(value: string | string[] | undefined) {diff --git a/web/src/features/events/index.ts b/web/src/features/events/index.tsdeleted file mode 100644index 58b558a3b1..0000000000--- a/web/src/features/events/index.ts+++ /dev/null@@ -1,34 +0,0 @@-// The events feature's public client surface (RFC rule 8). Named re-exports-// only — exactly what other features already imported.-//-// EventsTable stays a deep import: it reaches the whole trace/peek graph, so-// re-exporting it here would make every consumer of this index part of that-// graph and turn several feature pairs into runtime cycles.-export {- V4PreviewToggleRow,- V4SidebarToggle,-} from "@/src/features/events/components/V4SidebarToggle";-export {- canReuseOutlierPlaceholder,- formatBucketRange,- OUTLIER_STRIP_STEP_LADDER_SECONDS,- outlierStripResultColumn,- pickChartGranularity,-} from "@/src/features/events/components/outlier-strip/lib/binning";-export { observationEventsFilterConfig } from "@/src/features/events/config/filter-config";-export { useEventsFilterOptions } from "@/src/features/events/hooks/useEventsFilterOptions";-export { useEventsTraceData } from "@/src/features/events/hooks/useEventsTraceData";-export { useMetadataValueOptions } from "@/src/features/events/hooks/useMetadataValueOptions";-export { useReadPath } from "@/src/features/events/hooks/useReadPath";-export type { ResolvedReadPath } from "@/src/features/events/hooks/useReadPath";-export {- buildEventsTablePathForColumnFilter,- buildEventsTablePathForMetadataFilter,- buildEventsTablePathForObservationType,- buildEventsTablePathForSpanName,- type MetadataFilterOperator,-} from "@/src/features/events/lib/eventsTablePaths";-export { V4_PREVIEW_LABEL } from "@/src/features/events/lib/v4PreviewLabel";-// shouldAutoEnableV4 / canToggleV4 stay on the deep lib path (or a future-// server surface). Re-exporting them here would make every server consumer of-// the client door pull V4PreviewToggleRow and blow up Turbopack RSC builds.diff --git a/web/src/features/events/lib/appRootDefault.clienttest.ts b/web/src/features/events/lib/appRootDefault.clienttest.tsindex d9d54a648d..80d4968991 100644--- a/web/src/features/events/lib/appRootDefault.clienttest.ts+++ b/web/src/features/events/lib/appRootDefault.clienttest.ts@@ -17,7 +17,7 @@ import {getSdkVersionCapability,getSdkVersionCapabilityStatus,toSdkVersionInfo,-} from "@/src/features/sdk-version";+} from "@/src/features/sdk-version/lib/sdkVersionCapabilities";const levelFilter: FilterState[number] = {column: "level",diff --git a/web/src/features/events/presetDemotionOnUserEdit.clienttest.tsx b/web/src/features/events/presetDemotionOnUserEdit.clienttest.tsxindex 9b9bc798b9..a4b7fe0f96 100644--- a/web/src/features/events/presetDemotionOnUserEdit.clienttest.tsx+++ b/web/src/features/events/presetDemotionOnUserEdit.clienttest.tsx@@ -13,14 +13,12 @@ import {} from "@langfuse/shared";import { useCallback, useRef } from "react";import { useStore } from "zustand";-import { useEventsSearchBar } from "@/src/features/search-bar";-import {- type FilterConfig,- useSidebarFilterState,-} from "@/src/features/filters";+import { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";+import type { FilterConfig } from "@/src/features/filters/lib/filter-config";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";import { useTableViewManager } from "../../components/table/table-view-presets/hooks/useTableViewManager";import { KeyValueFilterBuilder } from "@/src/components/table/KeyValueFilterBuilder";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import {demoteViewOnUserFilterEdit,type ViewDemotionControllers,diff --git a/web/src/features/events/server/eventsRouter.ts b/web/src/features/events/server/eventsRouter.tsindex 4e3d9e83b4..db967a2a10 100644--- a/web/src/features/events/server/eventsRouter.ts+++ b/web/src/features/events/server/eventsRouter.ts@@ -5,7 +5,7 @@ import { env } from "@/src/env.mjs";import {getContextualFeatureFlags,hasInternalAccess,-} from "@/src/features/feature-flags/server";+} from "@/src/features/feature-flags/utils";import {createTRPCRouter,protectedProjectProcedure,@@ -39,7 +39,7 @@ import {EVENT_FILTER_OPTIONS_COLUMNS,} from "./eventsService";import { loadTraceTranscript } from "./loadTraceTranscript";-import { recordTrpcAccess } from "@/src/ee/features/access-audit-log/server";+import { recordTrpcAccess } from "@/src/ee/features/access-audit-log/server/recordAccessEvent";import {instrumentAsync,getCurrentSpan,@@ -54,7 +54,8 @@ import {import {AgentGraphDataSchema,type AgentGraphDataResponse,-} from "@/src/features/trace-graph-view/server";+} from "@/src/features/trace-graph-view/types";+import type * as opentelemetry from "@opentelemetry/api";const GetAllEventsInput = EventsTableOptions.safeExtend({diff --git a/web/src/features/events/server/eventsService.ts b/web/src/features/events/server/eventsService.tsindex 63b6870fff..a43db448a8 100644--- a/web/src/features/events/server/eventsService.ts+++ b/web/src/features/events/server/eventsService.ts@@ -28,7 +28,7 @@ import {type EventFilterOptionColumn,type ClickhouseQueryOpts,} from "@langfuse/shared/src/server";-import { aggregateScores } from "@/src/features/scores/server";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";type TimeFilter = z.infer<typeof timeFilter>;const TRACE_SCORE_SCOPE_FILTER: FilterCondition[] = [diff --git a/web/src/features/events/server/index.ts b/web/src/features/events/server/index.tsdeleted file mode 100644index c534cee138..0000000000--- a/web/src/features/events/server/index.ts+++ /dev/null@@ -1,15 +0,0 @@-// The events feature's server surface (RFC rule 9, amended): server code-// reaches events' ClickHouse services through here, never through the-// client-safe root index.-export type { EventBatchIOOutput } from "@/src/features/events/server/eventsRouter";-export {- getEventFilterNumericRange,- getEventFilterValuePage,-} from "@/src/features/events/server/eventsService";-export { observationEventsFilterConfig } from "@/src/features/events/config/filter-config";-export {- canToggleV4,- isV4UpgradeUiAvailable,- shouldAutoEnableV4,- V4_DEFAULT_ENABLED_FROM_AT,-} from "@/src/features/events/lib/v4Rollout";diff --git a/web/src/features/events/systemPresetSearchBarRoundTrip.clienttest.ts b/web/src/features/events/systemPresetSearchBarRoundTrip.clienttest.tsindex 4561fe800a..4eb5e9b631 100644--- a/web/src/features/events/systemPresetSearchBarRoundTrip.clienttest.ts+++ b/web/src/features/events/systemPresetSearchBarRoundTrip.clienttest.ts@@ -6,7 +6,8 @@ import {getSystemTableViewPresets,type FilterState,} from "@langfuse/shared";-import { filterStateToQueryText, planCommit } from "@/src/features/search-bar";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";+import { planCommit } from "@/src/features/search-bar/lib/commit";// Catalog guard for the LFE-14699 demote-on-user-edit no-op check// (demoteViewOnUserFilterEdit): a user-origin filter write only demotes thediff --git a/web/src/features/experiments/ExperimentResultsPage.tsx b/web/src/features/experiments/ExperimentResultsPage.tsxindex 8718b875a6..b3117d4722 100644--- a/web/src/features/experiments/ExperimentResultsPage.tsx+++ b/web/src/features/experiments/ExperimentResultsPage.tsx@@ -1,7 +1,7 @@import { useRouter } from "next/router";import Page from "@/src/components/layouts/Page";import { api } from "@/src/utils/api";-import { ExperimentItemsTable } from "@/src/features/experiments/components/table";+import { default as ExperimentItemsTable } from "@/src/features/experiments/components/table/ExperimentItemsTable";import { ExperimentOverviewPanel } from "@/src/features/experiments/components/ExperimentOverviewPanel";import {OverviewPanelLayout,@@ -14,7 +14,7 @@ import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimimport { Spinner } from "@/src/components/design-system/Spinner/Spinner";import { ExperimentSelectionControls } from "@/src/features/experiments/components/ExperimentSelectionControls";import { useIoRenderModeLocalStorage } from "@/src/components/table/data-table-io-render-mode-switch";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {diffModeChangedProps,layoutChangedProps,diff --git a/web/src/features/experiments/ExperimentsPage.tsx b/web/src/features/experiments/ExperimentsPage.tsxindex 0ed46ed73b..166a4de179 100644--- a/web/src/features/experiments/ExperimentsPage.tsx+++ b/web/src/features/experiments/ExperimentsPage.tsx@@ -7,10 +7,10 @@ import {DialogTrigger,} from "@/src/components/ui/dialog";import { CreateExperimentsForm } from "@/src/features/experiments/components/CreateExperimentsForm";-import { ExperimentsTable } from "@/src/features/experiments/components/table";+import { default as ExperimentsTable } from "@/src/features/experiments/components/table/ExperimentsTable";import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useHasProjectAccess } from "@/src/features/rbac";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { V4MigrationDelayBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";import { api } from "@/src/utils/api";import { FlaskConical } from "@langfuse/icons";diff --git a/web/src/features/experiments/components/CreateExperimentsForm.tsx b/web/src/features/experiments/components/CreateExperimentsForm.tsxindex 30ec30c435..03960bc895 100644--- a/web/src/features/experiments/components/CreateExperimentsForm.tsx+++ b/web/src/features/experiments/components/CreateExperimentsForm.tsx@@ -13,7 +13,7 @@ import {CardContent,CardFooter,} from "@/src/components/ui/card";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {DialogHeader,DialogTitle,@@ -34,7 +34,7 @@ import {PopoverTrigger,} from "@/src/components/ui/popover";import Link from "next/link";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type CreateExperiment } from "@/src/features/experiments/types";import { MultiStepExperimentForm } from "@/src/features/experiments/components/MultiStepExperimentForm";import { RemoteExperimentUpsertForm } from "@/src/features/experiments/components/RemoteExperimentUpsertForm";diff --git a/web/src/features/experiments/components/ExperimentBaselineControls.tsx b/web/src/features/experiments/components/ExperimentBaselineControls.tsxindex 724393ff13..3eef6720c1 100644--- a/web/src/features/experiments/components/ExperimentBaselineControls.tsx+++ b/web/src/features/experiments/components/ExperimentBaselineControls.tsx@@ -13,7 +13,7 @@ import {UNNAMED_DATASET_LABEL,} from "@/src/features/experiments/constants/comparison";import { cn } from "@/src/utils/tailwind";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { baselineChangedProps } from "@/src/features/experiments/lib/analytics";type ExperimentBaselineControlsProps = {diff --git a/web/src/features/experiments/components/ExperimentChartsLayout.tsx b/web/src/features/experiments/components/ExperimentChartsLayout.tsxindex 96ac6e5047..8e394cc32f 100644--- a/web/src/features/experiments/components/ExperimentChartsLayout.tsx+++ b/web/src/features/experiments/components/ExperimentChartsLayout.tsx@@ -18,7 +18,7 @@ import {type MetricOption,type ScoreCoverageByLevel,} from "@/src/features/experiments/types/charts";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { chartMetricChangedProps } from "@/src/features/experiments/lib/analytics";const PANEL_IDS = ["charts", "table"];diff --git a/web/src/features/experiments/components/ExperimentComparisonSelector.tsx b/web/src/features/experiments/components/ExperimentComparisonSelector.tsxindex 52e39cefc9..b898b02a36 100644--- a/web/src/features/experiments/components/ExperimentComparisonSelector.tsx+++ b/web/src/features/experiments/components/ExperimentComparisonSelector.tsx@@ -13,7 +13,7 @@ import {import { useExperimentSearch } from "@/src/features/experiments/hooks/useExperimentSearch";import { type ExperimentNameOption } from "@/src/features/experiments/hooks/useExperimentNames";import { formatRunRecency } from "@/src/features/experiments/fns/formatRunRecency";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {autoComparisonPreferenceChangedProps,comparisonChangedProps,diff --git a/web/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments.clienttest.tsx b/web/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments.clienttest.tsxindex d8ec5e148b..68de731489 100644--- a/web/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments.clienttest.tsx+++ b/web/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments.clienttest.tsx@@ -21,9 +21,12 @@ vi.mock("@/src/utils/api", () => ({sendAsPostOption: {},}));-vi.mock("@/src/features/evals", () => ({- buildSelectedSampleObject: () => ({}),-}));+vi.mock(+ "@/src/features/evals/v2/fns/evaluatorTesting/buildSelectedSampleObject",+ () => ({+ buildSelectedSampleObject: () => ({}),+ }),+);vi.mock("@/src/features/experiments/components/ExperimentEvaluatorAssignments/components/ExperimentEvaluatorAssignmentsEditor/ExperimentEvaluatorAssignmentsEditor",diff --git a/web/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments.tsx b/web/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments.tsxindex 8984f51a25..d3793d0f75 100644--- a/web/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments.tsx+++ b/web/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments.tsx@@ -2,11 +2,11 @@ import { subDays } from "date-fns";import { forwardRef, useState } from "react";import { Skeleton } from "@/src/components/ui/skeleton";-import {- buildSelectedSampleObject,- type RuleDraft,- type RuleEvaluatorOption,-} from "@/src/features/evals";+import { buildSelectedSampleObject } from "@/src/features/evals/v2/fns/evaluatorTesting/buildSelectedSampleObject";+import type {+ RuleDraft,+ RuleEvaluatorOption,+} from "@/src/features/evals/v2/types/rules";import { api, sendAsPostOption } from "@/src/utils/api";import { ExperimentEvaluatorAssignmentsEditor } from "@/src/features/experiments/components/ExperimentEvaluatorAssignments/components/ExperimentEvaluatorAssignmentsEditor/ExperimentEvaluatorAssignmentsEditor";import { buildExperimentEvaluatorSampleObject } from "@/src/features/experiments/components/ExperimentEvaluatorAssignments/fns/buildExperimentEvaluatorSampleObject";diff --git a/web/src/features/experiments/components/ExperimentEvaluatorAssignments/components/ExperimentEvaluatorAssignmentsEditor/ExperimentEvaluatorAssignmentsEditor.tsx b/web/src/features/experiments/components/ExperimentEvaluatorAssignments/components/ExperimentEvaluatorAssignmentsEditor/ExperimentEvaluatorAssignmentsEditor.tsxindex 12a0d7cec0..27c135e9e8 100644--- a/web/src/features/experiments/components/ExperimentEvaluatorAssignments/components/ExperimentEvaluatorAssignmentsEditor/ExperimentEvaluatorAssignmentsEditor.tsx+++ b/web/src/features/experiments/components/ExperimentEvaluatorAssignments/components/ExperimentEvaluatorAssignmentsEditor/ExperimentEvaluatorAssignmentsEditor.tsx@@ -4,11 +4,13 @@ import { useStore } from "zustand";import { Button } from "@/src/components/ui/button";import {createRuleSetupStore,- EvaluatorAssignmentsEditor,isRuleDraftDirty,- type RuleDraft,- type RuleEvaluatorOption,-} from "@/src/features/evals";+} from "@/src/features/evals/v2/stores/createRuleSetupStore";+import { EvaluatorAssignmentsEditor } from "@/src/features/evals/v2/components/Rules/EvaluatorAssignmentsEditor/EvaluatorAssignmentsEditor";+import type {+ RuleDraft,+ RuleEvaluatorOption,+} from "@/src/features/evals/v2/types/rules";import type { ExperimentEvaluatorAssignmentsHandle } from "@/src/features/experiments/components/ExperimentEvaluatorAssignments/types/experimentEvaluatorAssignmentsHandle";export const ExperimentEvaluatorAssignmentsEditor = forwardRef<diff --git a/web/src/features/experiments/components/ExperimentMetricStrip.tsx b/web/src/features/experiments/components/ExperimentMetricStrip.tsxindex fff2cf817a..e81cab9421 100644--- a/web/src/features/experiments/components/ExperimentMetricStrip.tsx+++ b/web/src/features/experiments/components/ExperimentMetricStrip.tsx@@ -12,7 +12,7 @@ import {SelectValue,} from "@/src/components/ui/select";import { ScoreTag } from "@/src/components/ScoreTag";-import { WidgetContent } from "@/src/features/widgets";+import { WidgetContent } from "@/src/features/widgets/components/InlineWidget";import { type QueryType } from "@langfuse/shared/query";import { type MetricOption } from "@/src/features/experiments/types/charts";import { buildWidgetConfigFromId } from "@/src/features/experiments/utils/charts";diff --git a/web/src/features/experiments/components/ExperimentSelectionControls.tsx b/web/src/features/experiments/components/ExperimentSelectionControls.tsxindex 42d2c8e2cf..29a1528540 100644--- a/web/src/features/experiments/components/ExperimentSelectionControls.tsx+++ b/web/src/features/experiments/components/ExperimentSelectionControls.tsx@@ -3,7 +3,7 @@ import { useRouter } from "next/router";import { type UrlUpdateType } from "use-query-params";import { useExperimentComparisonAutoSelect } from "@/src/features/experiments/hooks/useExperimentComparisonAutoSelect";import { useExperimentNames } from "@/src/features/experiments/hooks/useExperimentNames";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {comparisonChangedProps,type ExperimentComparisonSource,diff --git a/web/src/features/experiments/components/MultiStepExperimentForm.tsx b/web/src/features/experiments/components/MultiStepExperimentForm.tsxindex c339bdd839..e69c39027e 100644--- a/web/src/features/experiments/components/MultiStepExperimentForm.tsx+++ b/web/src/features/experiments/components/MultiStepExperimentForm.tsx@@ -1,5 +1,5 @@/* eslint-disable @repo/no-null-render, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import React, { useEffect, useRef, useState } from "react";import { Button } from "@/src/components/ui/button";import { Form } from "@/src/components/ui/form";@@ -24,8 +24,8 @@ import { zodResolver } from "@hookform/resolvers/zod";import { useForm, type UseFormReturn } from "react-hook-form";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";-import { useModelParams } from "@/src/features/playground";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useModelParams } from "@/src/features/playground/page/hooks/useModelParams";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useEvaluatorDefaults } from "@/src/features/experiments/hooks/useEvaluatorDefaults";import { useExperimentEvaluatorData } from "@/src/features/experiments/hooks/useExperimentEvaluatorData";import { useExperimentNameValidation } from "@/src/features/experiments/hooks/useExperimentNameValidation";@@ -33,7 +33,7 @@ import { useExperimentPromptData } from "@/src/features/experiments/hooks/useExpimport { getExistingEvaluators } from "@/src/features/experiments/hooks/useExperimentEvaluatorSelection";import { useExperimentV2EvaluatorSelection } from "@/src/features/experiments/hooks/useExperimentV2EvaluatorSelection";import { getFinalModelParams } from "@/src/utils/getFinalModelParams";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { Skeleton } from "@/src/components/ui/skeleton";import {CreateExperimentData,diff --git a/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx b/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsxindex 8bbf8ea832..93ff9c9b5f 100644--- a/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx+++ b/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx@@ -22,7 +22,8 @@ import {} from "@/src/components/ui/form";import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { api } from "@/src/utils/api";-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { getFormattedPayload } from "@/src/features/experiments/utils/format";import { type Prisma } from "@langfuse/shared";import { Spinner } from "@/src/components/design-system/Spinner/Spinner";diff --git a/web/src/features/experiments/components/RemoteExperimentUpsertForm.tsx b/web/src/features/experiments/components/RemoteExperimentUpsertForm.tsxindex 6375aad08b..ca493f977f 100644--- a/web/src/features/experiments/components/RemoteExperimentUpsertForm.tsx+++ b/web/src/features/experiments/components/RemoteExperimentUpsertForm.tsx@@ -1,6 +1,7 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. *//* eslint-disable @repo/no-null-render */-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import React, { useState } from "react";import * as AccordionPrimitive from "@radix-ui/react-accordion";import { useForm, useFieldArray } from "react-hook-form";@@ -29,7 +30,7 @@ import { Input } from "@/src/components/ui/input";import { Switch } from "@/src/components/design-system/Switch/Switch";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { CodeSection } from "@/src/components/design-system/CodeSection/CodeSection";import { type Prisma, WebhookProtectedHeaders } from "@langfuse/shared";diff --git a/web/src/features/experiments/components/filters/ExperimentFilterSidebar.tsx b/web/src/features/experiments/components/filters/ExperimentFilterSidebar.tsxindex 8c975a19ce..3411f5e4af 100644--- a/web/src/features/experiments/components/filters/ExperimentFilterSidebar.tsx+++ b/web/src/features/experiments/components/filters/ExperimentFilterSidebar.tsx@@ -1,7 +1,7 @@import { type ComponentProps } from "react";import { type FilterState } from "@langfuse/shared";import { useDataTableControls } from "@/src/components/table/data-table-controls";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { ExperimentFilterSidebarView } from "./ExperimentFilterSidebarView";import { editExperimentFilter } from "./experimentFilterEditing";diff --git a/web/src/features/experiments/components/steps/PromptModelStep.tsx b/web/src/features/experiments/components/steps/PromptModelStep.tsxindex 11f7aa09b8..eae86bbb4b 100644--- a/web/src/features/experiments/components/steps/PromptModelStep.tsx+++ b/web/src/features/experiments/components/steps/PromptModelStep.tsx@@ -23,7 +23,7 @@ import {} from "@/src/components/ui/popover";import { CheckIcon, PlusIcon, EyeIcon, TriangleAlert } from "@langfuse/icons";import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";-import { CreateOrEditLLMSchemaDialog } from "@/src/features/playground";+import { CreateOrEditLLMSchemaDialog } from "@/src/features/playground/page/components/CreateOrEditLLMSchemaDialog";import {hasPromptToolStructuredOutputConflict,PROMPT_TOOL_STRUCTURED_OUTPUT_CONFLICT_MESSAGE,diff --git a/web/src/features/experiments/components/table/ExperimentGridCell.tsx b/web/src/features/experiments/components/table/ExperimentGridCell.tsxindex 37cf70753d..acf05e28fa 100644--- a/web/src/features/experiments/components/table/ExperimentGridCell.tsx+++ b/web/src/features/experiments/components/table/ExperimentGridCell.tsx@@ -14,9 +14,10 @@ import { useMemo, Fragment, useState } from "react";import {type BaselineDiff,calculateNumericDiff,- computeScoreDiffs,- DiffLabel,-} from "@/src/features/datasets";+} from "@/src/features/datasets/lib/calculateBaselineDiff";++import { computeScoreDiffs } from "@/src/features/datasets/lib/computeScoreDiffs";+import { DiffLabel } from "@/src/features/datasets/components/DiffLabel";import { Separator } from "@/src/components/ui/separator";import { type VisibilityState } from "@tanstack/react-table";import {@@ -32,7 +33,7 @@ import { copyTextToClipboard } from "@/src/utils/clipboard";import { api } from "@/src/utils/api";import { Skeleton } from "@/src/components/ui/skeleton";import { JSONView } from "@/src/components/ui/CodeJsonViewer";-import { decomposeAggregateScoreKey } from "@/src/features/scores";+import { decomposeAggregateScoreKey } from "@/src/features/scores/lib/aggregateScores";import { cn } from "@/src/utils/tailwind";import Link from "next/link";import { type ScoreLevel } from "@/src/components/ScoreTag";diff --git a/web/src/features/experiments/components/table/ExperimentGridSummaryValues.tsx b/web/src/features/experiments/components/table/ExperimentGridSummaryValues.tsxindex db013a74aa..2e679f00e3 100644--- a/web/src/features/experiments/components/table/ExperimentGridSummaryValues.tsx+++ b/web/src/features/experiments/components/table/ExperimentGridSummaryValues.tsx@@ -1,12 +1,12 @@import { useMemo } from "react";import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";-import { decomposeAggregateScoreKey } from "@/src/features/scores";+import { decomposeAggregateScoreKey } from "@/src/features/scores/lib/aggregateScores";import { summariseScoreColumn } from "../../fns/summariseScoreColumn";import {formatScoreColumnAggregate,formatScoreValue,} from "../../fns/formatScoreColumnAggregate";-import { DiffLabel } from "@/src/features/datasets";+import { DiffLabel } from "@/src/features/datasets/components/DiffLabel";import { type ExperimentItemsTableRow } from "./types";import { type VisibilityState } from "@tanstack/react-table";diff --git a/web/src/features/experiments/components/table/ExperimentGridView.tsx b/web/src/features/experiments/components/table/ExperimentGridView.tsxindex 072c6c151d..a69ed07bcd 100644--- a/web/src/features/experiments/components/table/ExperimentGridView.tsx+++ b/web/src/features/experiments/components/table/ExperimentGridView.tsx@@ -26,8 +26,8 @@ import { useExperimentNames } from "@/src/features/experiments/hooks/useExperimeimport { cn } from "@/src/utils/tailwind";import { type DataTablePeekViewProps } from "@/src/components/table/peek";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";// Grid view row heights (matching DatasetCompareRunsTable)export const GRID_VIEW_ROW_HEIGHTS = {diff --git a/web/src/features/experiments/components/table/ExperimentItemsTable.tsx b/web/src/features/experiments/components/table/ExperimentItemsTable.tsxindex e8cbc3677f..cc3e3b87fc 100644--- a/web/src/features/experiments/components/table/ExperimentItemsTable.tsx+++ b/web/src/features/experiments/components/table/ExperimentItemsTable.tsx@@ -8,17 +8,15 @@ import { DataTableControlsProvider } from "@/src/components/table/data-table-conimport { ExperimentFilterSidebar } from "../filters/ExperimentFilterSidebar";import { SearchableTableFilterLayout } from "@/src/components/table/resizable-filter-layout";import { useEffect, useMemo, useState, useRef, useCallback } from "react";-import { RunEvaluationDialog } from "@/src/features/batch-actions";+import { RunEvaluationDialog } from "@/src/features/batch-actions/components/RunEvaluationDialog/index";import { LightbulbIcon } from "@langfuse/icons";-import { useHasProjectAccess } from "@/src/features/rbac";-import {- TableActionMenu,- type TableAction,- TableSelectionManager,- useSelectAll,-} from "@/src/features/table";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";+import type { TableAction } from "@/src/features/table/types";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";+import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";import { usePaginationState } from "@/src/hooks/usePaginationState";-import { useSidebarFilterState } from "@/src/features/filters";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";import {getExperimentItemsColumnName,experimentItemsFilterConfig,@@ -36,23 +34,21 @@ import {getExperimentBatchEvaluationFilters,groupExperimentFilters,} from "../../lib/experimentFilterTargets";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {COMPARISON_OPERATOR_PROPERTY,itemRegressionFilterAppliedProps,scoreColumnScopeToggledProps,} from "@/src/features/experiments/lib/analytics";import { type ColumnGroupTogglePayload } from "@/src/components/table/DataTableColumnVisibilityFilter";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import {customRowHeightMenu,getRowHeightIOCharLimit,useAdjustableRowHeight,} from "@/src/components/table/data-table-row-height-switch";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { buildLocalIsoDatePresentation } from "@/src/utils/dates";import { usdFormatter, latencyFormatter } from "@/src/utils/numbers";import { type RowSelectionState } from "@tanstack/react-table";@@ -62,10 +58,11 @@ import {ExperimentGridView,GRID_VIEW_ROW_HEIGHTS,} from "./ExperimentGridView";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";-import { TableSearchBar, toObservedOptions } from "@/src/features/search-bar";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { useExperimentItemsSearchRegistry } from "../../hooks/useExperimentItemsSearchRegistry";import { useExperimentItemsTableData } from "../../hooks/useExperimentItemsTableData";import { useExpectedOutputVisibility } from "../../hooks/useExpectedOutputVisibility";@@ -83,10 +80,10 @@ import { type DataTablePeekViewProps } from "@/src/components/table/peek";import { cn } from "@/src/utils/tailwind";import {collectPresentScoreKeys,- composeAggregateScoreKey,- createScoreColumns,withPresentScoreKeys,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/scoreColumns";+import { composeAggregateScoreKey } from "@/src/features/scores/lib/aggregateScores";+import { createScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";import { Skeleton } from "@/src/components/ui/skeleton";import {ExperimentCompareTable,@@ -98,11 +95,9 @@ import {useExperimentItemsFilterOptions,type ScoreColumnDef,} from "@/src/features/experiments/hooks/useExperimentItemsFilterOptions";-import {- calculateNumericDiff,- computeScoreDiffs,- DiffLabel,-} from "@/src/features/datasets";+import { calculateNumericDiff } from "@/src/features/datasets/lib/calculateBaselineDiff";+import { computeScoreDiffs } from "@/src/features/datasets/lib/computeScoreDiffs";+import { DiffLabel } from "@/src/features/datasets/components/DiffLabel";import { describeRunComparison } from "@/src/features/experiments/fns/describeRunComparison";import { TablePeekViewExperimentItemDetail } from "@/src/components/table/peek/TablePeekViewExperimentItemDetail";import { NotRecordedMetric } from "./NotRecordedMetric";diff --git a/web/src/features/experiments/components/table/ExperimentScoreMatrix.tsx b/web/src/features/experiments/components/table/ExperimentScoreMatrix.tsxindex d8762cfc81..35f1028b2c 100644--- a/web/src/features/experiments/components/table/ExperimentScoreMatrix.tsx+++ b/web/src/features/experiments/components/table/ExperimentScoreMatrix.tsx@@ -15,11 +15,11 @@ import {TooltipContent,TooltipTrigger,} from "@/src/components/ui/tooltip";-import { DiffLabel } from "@/src/features/datasets";+import { DiffLabel } from "@/src/features/datasets/components/DiffLabel";import {getScoreDataTypeExplanation,splitScoreDataTypeIcon,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/scoreColumns";import {formatScoreColumnAggregate,formatScoreValue,diff --git a/web/src/features/experiments/components/table/ExperimentsTable.tsx b/web/src/features/experiments/components/table/ExperimentsTable.tsxindex b661746516..435254e343 100644--- a/web/src/features/experiments/components/table/ExperimentsTable.tsx+++ b/web/src/features/experiments/components/table/ExperimentsTable.tsx@@ -12,15 +12,14 @@ import {} from "@/src/components/table/data-table-controls";import { StickySearchableTableFilterLayout } from "@/src/components/table/resizable-filter-layout";import { useEffect, useMemo, useState, useRef, useCallback } from "react";-import {- useQueryFilterState,- useSidebarFilterState,-} from "@/src/features/filters";+import { useQueryFilterState } from "@/src/features/filters/hooks/useFilterState";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";import { usePaginationState } from "@/src/hooks/usePaginationState";import { experimentsFieldRegistry } from "@/src/features/experiments/constants/experimentsSearchRegistry";import { awaitsDatasetNames } from "@/src/features/experiments/fns/awaitsDatasetNames";import { withDatasetNamesResolved } from "@/src/features/experiments/fns/datasetNameFilter";-import { TableSearchBar, toObservedOptions } from "@/src/features/search-bar";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import {getExperimentsFilterConfig,getExperimentsColumnName,@@ -36,7 +35,7 @@ import {buildExperimentPath,} from "@langfuse/shared";import { numberFormatter } from "@/src/utils/numbers";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import {customRowHeightMenu,isCompactRowHeight,@@ -46,41 +45,37 @@ import {import { useTableDateRange } from "@/src/hooks/useTableDateRange";import { toAbsoluteTimeRange } from "@/src/utils/date-range-utils";import { TableHeaderControls } from "@/src/components/table/TableHeaderControls";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { GitCompareArrows, LightbulbIcon } from "@langfuse/icons";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";import Link from "next/link";-import {- TableActionMenu,- type TableAction,- TableSelectionManager,-} from "@/src/features/table";+import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";+import { type TableAction } from "@/src/features/table/types";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";import { Badge } from "@/src/components/design-system/Badge/Badge";import { type VisibilityState } from "@tanstack/react-table";import { useStore } from "zustand";import { createIdTableColumn } from "@/src/components/design-system/table/columns/createIdTableColumn";import { Skeleton } from "@/src/components/ui/skeleton";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";import { useRouter } from "next/router";import {collectPresentScoreKeys,- collectScoreNameCoverage,revealScoreColumns,scoreFilters,- useScoreColumns,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/scoreColumns";+import { collectScoreNameCoverage } from "@/src/features/scores/lib/aggregateScores";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";import { useExperimentsTableData } from "../../hooks/useExperimentsTableData";import { type ExperimentsTableRow, type ExperimentsTableProps } from "./types";import { useExperimentFilterOptions } from "../../hooks/useExperimentFilterOptions";-import { RunEvaluationDialog } from "@/src/features/batch-actions";-import { useHasProjectAccess } from "@/src/features/rbac";+import { RunEvaluationDialog } from "@/src/features/batch-actions/components/RunEvaluationDialog/index";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ExperimentChartsLayout } from "../ExperimentChartsLayout";import { metricOptionsFromScoreColumns } from "../../fns/metricOptionsFromScoreColumns";import {@@ -89,7 +84,7 @@ import {} from "@/src/features/experiments/store/experimentsTableStore";import { useExperimentsTableSelectionSync } from "@/src/features/experiments/hooks/useExperimentsTableSelectionSync";import { createExperimentMetricColumn } from "./createExperimentMetricColumn";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {baselineChangedProps,comparisonChangedProps,diff --git a/web/src/features/experiments/components/table/ScoreColumnHeaderSummary.tsx b/web/src/features/experiments/components/table/ScoreColumnHeaderSummary.tsxindex 49d0393b18..8f4fce4c3a 100644--- a/web/src/features/experiments/components/table/ScoreColumnHeaderSummary.tsx+++ b/web/src/features/experiments/components/table/ScoreColumnHeaderSummary.tsx@@ -1,6 +1,6 @@import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";-import { DiffLabel } from "@/src/features/datasets";-import { splitScoreDataTypeIcon } from "@/src/features/scores";+import { DiffLabel } from "@/src/features/datasets/components/DiffLabel";+import { splitScoreDataTypeIcon } from "@/src/features/scores/lib/scoreColumns";import {type ScoreColumnDataType,type ScoreColumnSummary,diff --git a/web/src/features/experiments/components/table/index.ts b/web/src/features/experiments/components/table/index.tsdeleted file mode 100644index 3f2be4293f..0000000000--- a/web/src/features/experiments/components/table/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export { default as ExperimentsTable } from "./ExperimentsTable";-export { default as ExperimentItemsTable } from "./ExperimentItemsTable";-export * from "./types";-export * from "./filter-config";diff --git a/web/src/features/experiments/config/experiment-items-filter-config.ts b/web/src/features/experiments/config/experiment-items-filter-config.tsindex b1149a704d..cf2d1e24c5 100644--- a/web/src/features/experiments/config/experiment-items-filter-config.ts+++ b/web/src/features/experiments/config/experiment-items-filter-config.ts@@ -1,4 +1,4 @@-import type { FilterConfig } from "@/src/features/filters";+import type { FilterConfig } from "@/src/features/filters/lib/filter-config";import { renderLevelIcon } from "@/src/components/ObservationLevelTag";import type { ColumnDefinition, ObservationLevelType } from "@langfuse/shared";diff --git a/web/src/features/experiments/constants/charts.ts b/web/src/features/experiments/constants/charts.tsindex ddf7eae936..a68db3d600 100644--- a/web/src/features/experiments/constants/charts.ts+++ b/web/src/features/experiments/constants/charts.ts@@ -3,7 +3,7 @@ import type {ScoreLevel,ScoreMetricSpec,} from "@/src/features/experiments/types/charts";-import type { WidgetDimensionConfig } from "@/src/features/widgets";+import type { WidgetDimensionConfig } from "@/src/features/widgets/hooks/useWidgetQuery";import type { FilterCondition } from "@langfuse/shared";export const MAX_EXPERIMENT_CHARTS = 4;diff --git a/web/src/features/experiments/constants/experimentItemsSearchRegistry.clienttest.ts b/web/src/features/experiments/constants/experimentItemsSearchRegistry.clienttest.tsindex 59b9f8bd06..0ec06cc321 100644--- a/web/src/features/experiments/constants/experimentItemsSearchRegistry.clienttest.ts+++ b/web/src/features/experiments/constants/experimentItemsSearchRegistry.clienttest.ts@@ -6,7 +6,8 @@ import {type FilterState,} from "@langfuse/shared";import { EXPERIMENT_ITEMS_FIELD_REGISTRY } from "./experimentItemsSearchRegistry";-import { planCommit, filterStateToQueryText } from "@/src/features/search-bar";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";import { experimentItemsFilterTargeting } from "../lib/experimentItemsFilterTargeting";import {completeExperimentFilter,diff --git a/web/src/features/experiments/constants/experimentItemsSearchRegistry.ts b/web/src/features/experiments/constants/experimentItemsSearchRegistry.tsindex e5f4375911..6cc6e41ef4 100644--- a/web/src/features/experiments/constants/experimentItemsSearchRegistry.ts+++ b/web/src/features/experiments/constants/experimentItemsSearchRegistry.ts@@ -1,5 +1,5 @@import { experimentItemsFilterConfig } from "@/src/features/experiments/config/experiment-items-filter-config";-import { fieldRegistryFromColumns } from "@/src/features/search-bar";+import { fieldRegistryFromColumns } from "@/src/features/search-bar/lib/fields";const facetColumns = new Set(experimentItemsFilterConfig.facets.map((facet) => facet.column),diff --git a/web/src/features/experiments/constants/experimentsSearchRegistry.ts b/web/src/features/experiments/constants/experimentsSearchRegistry.tsindex 2b6a7067d8..eea861be14 100644--- a/web/src/features/experiments/constants/experimentsSearchRegistry.ts+++ b/web/src/features/experiments/constants/experimentsSearchRegistry.ts@@ -2,8 +2,9 @@import {type FieldRegistry,fieldRegistryFromColumns,-} from "@/src/features/search-bar";-import type { FilterConfig } from "@/src/features/filters";+} from "@/src/features/search-bar/lib/fields";++import type { FilterConfig } from "@/src/features/filters/lib/filter-config";import { experimentsFilterConfig } from "@/src/features/experiments/components/table/filter-config";diff --git a/web/src/features/experiments/fns/pickDefaultStripMetric.ts b/web/src/features/experiments/fns/pickDefaultStripMetric.tsindex eea4511ec5..f82901e7d1 100644--- a/web/src/features/experiments/fns/pickDefaultStripMetric.ts+++ b/web/src/features/experiments/fns/pickDefaultStripMetric.ts@@ -3,7 +3,7 @@ import type {MetricOption,ScoreCoverageByLevel,} from "@/src/features/experiments/types/charts";-import { normalizeScoreName } from "@/src/features/scores";+import { normalizeScoreName } from "@/src/features/scores/lib/aggregateScores";/** Score chart ids are `${level}-score-${dataType}:${scoreName}`. */const NUMERIC_SCORE_ID = /^(obs|experiment)-score-numeric:/;diff --git a/web/src/features/experiments/hooks/useExperimentAccess.ts b/web/src/features/experiments/hooks/useExperimentAccess.tsindex cd19aff242..ab23976860 100644--- a/web/src/features/experiments/hooks/useExperimentAccess.ts+++ b/web/src/features/experiments/hooks/useExperimentAccess.ts@@ -1,4 +1,4 @@-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";export function useExperimentAccess() {const { isV4: isV4BetaEnabled, isResolved } = useReadPath();diff --git a/web/src/features/experiments/hooks/useExperimentNames.ts b/web/src/features/experiments/hooks/useExperimentNames.tsindex 4d0960c809..a9885277b3 100644--- a/web/src/features/experiments/hooks/useExperimentNames.ts+++ b/web/src/features/experiments/hooks/useExperimentNames.ts@@ -1,5 +1,5 @@import { useMemo } from "react";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";export type ExperimentNameOption = {diff --git a/web/src/features/experiments/hooks/useExperimentPeekNavigation.ts b/web/src/features/experiments/hooks/useExperimentPeekNavigation.tsindex 1e759b58a4..bceb8279e0 100644--- a/web/src/features/experiments/hooks/useExperimentPeekNavigation.ts+++ b/web/src/features/experiments/hooks/useExperimentPeekNavigation.ts@@ -2,7 +2,7 @@ import { useCallback, useMemo } from "react";import { useQueryParam, StringParam } from "use-query-params";import { useRouter } from "next/router";import { useExperimentResultsState } from "./useExperimentResultsState";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { getPathnameWithoutBasePath } from "@/src/utils/api";type ExperimentTarget = {diff --git a/web/src/features/experiments/index.ts b/web/src/features/experiments/index.tsdeleted file mode 100644index 39b0c5c974..0000000000--- a/web/src/features/experiments/index.ts+++ /dev/null@@ -1,20 +0,0 @@-// The experiments feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-//-// filter-config and experiment-items-filter-config stay deep: filters'-// useFilterState imports them, and routing them here would close a runtime-// cycle. experimentsSearchRegistry stays deep (search-bar server imports-// it). ExperimentsTable, pages, and experimentsRouter stay off this door.-// useExperimentEvaluatorSelection stays deep so evals' template-selector-// does not load CreateExperimentsForm.-export { CreateExperimentsForm } from "@/src/features/experiments/components/CreateExperimentsForm";-export { ExperimentDisplaySettings } from "@/src/features/experiments/components/ExperimentDisplaySettings";-export { ExperimentPeekFooter } from "@/src/features/experiments/components/ExperimentPeekFooter";-export { useEvaluatorDefaults } from "@/src/features/experiments/hooks/useEvaluatorDefaults";-export { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";-export { useExperimentEvaluatorData } from "@/src/features/experiments/hooks/useExperimentEvaluatorData";-export { useExperimentPeekNavigation } from "@/src/features/experiments/hooks/useExperimentPeekNavigation";-export {- singleRunToExperimentsUrl,- toExperimentsResultsUrl,-} from "@/src/features/experiments/utils/experimentUrlTranslation";diff --git a/web/src/features/experiments/server/index.ts b/web/src/features/experiments/server/index.tsdeleted file mode 100644index f1060d5f6e..0000000000--- a/web/src/features/experiments/server/index.ts+++ /dev/null@@ -1,6 +0,0 @@-// The experiments feature's server surface (RFC rule 9, amended): the-// public-API experiment services MCP tools already imported by file path.-export {- listExperimentItemsForPublicApi,- listExperimentsForPublicApi,-} from "@/src/features/experiments/server/public";diff --git a/web/src/features/experiments/server/public/index.ts b/web/src/features/experiments/server/public/index.tsdeleted file mode 100644index a7adb85f1a..0000000000--- a/web/src/features/experiments/server/public/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export {- listExperimentItemsForPublicApi,- listExperimentsForPublicApi,-} from "./service";diff --git a/web/src/features/experiments/server/public/service.ts b/web/src/features/experiments/server/public/service.tsindex 6837392b57..292511f5d4 100644--- a/web/src/features/experiments/server/public/service.ts+++ b/web/src/features/experiments/server/public/service.ts@@ -12,7 +12,8 @@ import {encodeExperimentCursor,type GetExperimentItemsV1QueryType,type GetExperimentsV1QueryType,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/experiments";+import {queryExperimentItemsForPublicApi,queryExperimentSummariesForPublicApi,diff --git a/web/src/features/experiments/server/router.ts b/web/src/features/experiments/server/router.tsindex 0003ac12dd..a6e4c33f15 100644--- a/web/src/features/experiments/server/router.ts+++ b/web/src/features/experiments/server/router.ts@@ -54,8 +54,8 @@ import {parsePromptToolConfig,PROMPT_TOOL_STRUCTURED_OUTPUT_CONFLICT_MESSAGE,} from "@langfuse/shared";-import { throwIfNoProjectAccess } from "@/src/features/rbac";-import { aggregateScores } from "@/src/features/scores/server";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";import { describeVariableMismatch } from "@/src/features/experiments/fns/describeVariableMismatch";const ExperimentFilterOptions = z.object({diff --git a/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx b/web/src/features/external-media-storage/ExternalMediaStoragePage.tsxindex 9e7aebc58e..ee3c3f9ae4 100644--- a/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx+++ b/web/src/features/external-media-storage/ExternalMediaStoragePage.tsx@@ -10,13 +10,14 @@ import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";import { Button } from "@/src/components/ui/button";import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";import { Card } from "@/src/components/ui/card";-import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations";+import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations/components/IntegrationSettingsSkeleton";import { ExternalMediaStorageForm } from "@/src/features/external-media-storage/components/ExternalMediaStorageForm/ExternalMediaStorageForm";import { TestMediaObjectDialog } from "@/src/features/external-media-storage/components/TestMediaObjectDialog/TestMediaObjectDialog";import { testSignedMediaUrlCors } from "@/src/features/external-media-storage/fns/testSignedMediaUrlCors";import { type ExternalMediaStorageFormValues } from "@/src/features/external-media-storage/types";import { useExternalMediaStorage } from "@/src/features/external-media-storage/useExternalMediaStorage";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/external-media-storage/server/index.ts b/web/src/features/external-media-storage/server/index.tsdeleted file mode 100644index 9ce3e28f6f..0000000000--- a/web/src/features/external-media-storage/server/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { externalMediaStorageRouter } from "@/src/features/external-media-storage/server/router";-export { createExternalMediaStorageService } from "@/src/features/external-media-storage/server/service";diff --git a/web/src/features/external-media-storage/server/router.ts b/web/src/features/external-media-storage/server/router.tsindex 67039d75ae..3444888007 100644--- a/web/src/features/external-media-storage/server/router.ts+++ b/web/src/features/external-media-storage/server/router.ts@@ -8,7 +8,7 @@ import { z } from "zod";import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server/service";import { externalMediaStorageFormSchema } from "@/src/features/external-media-storage/types";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/external-media-storage/server/service.ts b/web/src/features/external-media-storage/server/service.tsindex bc6c459231..91b612267b 100644--- a/web/src/features/external-media-storage/server/service.ts+++ b/web/src/features/external-media-storage/server/service.ts@@ -16,8 +16,8 @@ import {validateExternalMediaStorageEndpoint,} from "@langfuse/shared/src/server";-import { getDisplayCredential } from "@/src/features/analytics-integrations/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { getDisplayCredential } from "@/src/features/analytics-integrations/server/displayCredential";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { isSameStorageDestination } from "@/src/features/automations/destinationUrl";import { type ExternalMediaStorageFormValues } from "@/src/features/external-media-storage/types";import {diff --git a/web/src/features/external-media-storage/useExternalMediaStorage.ts b/web/src/features/external-media-storage/useExternalMediaStorage.tsindex d01e9268f8..3e33eb6b08 100644--- a/web/src/features/external-media-storage/useExternalMediaStorage.ts+++ b/web/src/features/external-media-storage/useExternalMediaStorage.ts@@ -1,5 +1,5 @@import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";export function getExternalMediaStorageStatus(diff --git a/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx b/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsxindex 739109a612..f4e3f96c15 100644--- a/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx+++ b/web/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings.tsx@@ -1,5 +1,6 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { useState } from "react";import { useSession } from "next-auth/react";@@ -29,7 +30,7 @@ import { PersonalEnablementWarning } from "./PersonalEnablementWarning";import { canOpenPersonalFeaturePreviews } from "@/src/features/feature-previews/canOpenPersonalFeaturePreviews";import { ControlledFeaturePreviewModal } from "@/src/features/feature-previews/components/ControlledFeaturePreviewModal";import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/feature-flags/components/UserFeaturePreviewsControl.tsx b/web/src/features/feature-flags/components/UserFeaturePreviewsControl.tsxindex 9a153c30f2..ebfba632ad 100644--- a/web/src/features/feature-flags/components/UserFeaturePreviewsControl.tsx+++ b/web/src/features/feature-flags/components/UserFeaturePreviewsControl.tsx@@ -1,4 +1,5 @@-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { useId, useState, type ReactNode } from "react";import { useSession } from "next-auth/react";@@ -12,7 +13,7 @@ import {userFeaturePreviewFlags,type FeaturePreviewFlag,} from "@/src/features/feature-flags/available-flags";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/feature-flags/hooks/useInternalViewMode.ts b/web/src/features/feature-flags/hooks/useInternalViewMode.tsindex 957db8685c..8e562a99e7 100644--- a/web/src/features/feature-flags/hooks/useInternalViewMode.ts+++ b/web/src/features/feature-flags/hooks/useInternalViewMode.ts@@ -1,6 +1,6 @@import { useSession } from "next-auth/react";import { api } from "@/src/utils/api";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { hasInternalAccess } from "../utils";import { useInternalFeaturesEnabled } from "./useInternalFeaturesEnabled";diff --git a/web/src/features/feature-flags/index.ts b/web/src/features/feature-flags/index.tsdeleted file mode 100644index bb0f65ee9f..0000000000--- a/web/src/features/feature-flags/index.ts+++ /dev/null@@ -1,17 +0,0 @@-// The feature-flags feature's public client surface (RFC rule 8). Named-// re-exports only — the preview-flag catalog and enablement hook other-// features already imported by file path.-//-// OrganizationFeaturePreviewsSettings and UserFeaturePreviewsControl stay-// off this door: IOPreview and FeaturePreviewModal import the hook/catalog,-// and putting the settings UI here would load it into every trace IO-// preview. available-flags is also on the server door for server callers-// (rule 10). Pages stay off this door.-export { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";-export { useInternalFeaturesEnabled } from "./hooks/useInternalFeaturesEnabled";-export { InternalFeatureBadge } from "./components/InternalFeatureBadge";-export {- featurePreviewLabels,- type FeaturePreviewFlag,- type PersonalFeaturePreviewFlag,-} from "@/src/features/feature-flags/available-flags";diff --git a/web/src/features/feature-flags/internal-view-mode.ts b/web/src/features/feature-flags/internal-view-mode.tsdeleted file mode 100644index 46e12657b4..0000000000--- a/web/src/features/feature-flags/internal-view-mode.ts+++ /dev/null@@ -1,2 +0,0 @@-export { useInternalViewMode } from "./hooks/useInternalViewMode";-export { InternalViewModeDialog } from "./components/InternalViewModeDialog";diff --git a/web/src/features/feature-flags/server/index.ts b/web/src/features/feature-flags/server/index.tsdeleted file mode 100644index f0a37444d0..0000000000--- a/web/src/features/feature-flags/server/index.ts+++ /dev/null@@ -1,27 +0,0 @@-// The feature-flags feature's public server surface (RFC rules 8 and 10).-export {- featurePreviewFlags,- userFeaturePreviewFlags,- personalFeaturePreviewFlags,- isAdminOnlyFeaturePreviewFlag,- isOrganizationOnlyFeaturePreviewFlag,- INTERNAL_FEATURE_FLAG,-} from "@/src/features/feature-flags/available-flags";-export {- EMPTY_ORGANIZATION_FEATURE_PREVIEW_STATES,- getOrganizationFeaturePreviewStatesByUserId,- getUserFeaturePreviewManagementCapabilities,- setOrganizationFeatureFlagDefault,- setUserFeaturePreview,- setUserFeaturePreviewWithAuthorization,-} from "@/src/features/feature-flags/server/organizationFeatureFlags";-export {- getContextualFeatureFlags,- getFeaturePreviewOptOutFlag,- hasInternalAccess,-} from "@/src/features/feature-flags/utils";-export { getOrganizationFeaturePreviewDefaults } from "../fns/getOrganizationFeaturePreviewDefaults";-export {- parseFlags,- parseFlagsWithOrganizationDefaults,-} from "@/src/features/feature-flags/server/parseFlags";diff --git a/web/src/features/feature-previews/components/ControlledFeaturePreviewModal.tsx b/web/src/features/feature-previews/components/ControlledFeaturePreviewModal.tsxindex 2d5604c055..06e9b52a9d 100644--- a/web/src/features/feature-previews/components/ControlledFeaturePreviewModal.tsx+++ b/web/src/features/feature-previews/components/ControlledFeaturePreviewModal.tsx@@ -1,12 +1,12 @@/* eslint-disable no-nested-ternary */-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { useSession } from "next-auth/react";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useReadPath, V4_PREVIEW_LABEL } from "@/src/features/events";-import {- featurePreviewLabels,- useInternalFeaturesEnabled,-} from "@/src/features/feature-flags";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { V4_PREVIEW_LABEL } from "@/src/features/events/lib/v4PreviewLabel";+import { featurePreviewLabels } from "@/src/features/feature-flags/available-flags";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/feature-previews/components/FeaturePreviewModal.clienttest.tsx b/web/src/features/feature-previews/components/FeaturePreviewModal.clienttest.tsxindex 204790ae8d..d0788c2131 100644--- a/web/src/features/feature-previews/components/FeaturePreviewModal.clienttest.tsx+++ b/web/src/features/feature-previews/components/FeaturePreviewModal.clienttest.tsx@@ -10,11 +10,15 @@ import { FeaturePreviewModal } from "./FeaturePreviewModal";const mocks = vi.hoisted(() => ({ mutate: vi.fn(), isV4: true }));vi.mock("next-auth/react", () => ({ useSession: vi.fn() }));-vi.mock("@/src/features/events", () => ({+vi.mock("@/src/features/events/hooks/useReadPath", () => ({useReadPath: () => ({ isV4: mocks.isV4 }),V4_PREVIEW_LABEL: "Fast (Preview)",}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/events/lib/v4PreviewLabel", () => ({+ useReadPath: () => ({ isV4: mocks.isV4 }),+ V4_PREVIEW_LABEL: "Fast (Preview)",+}));+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));vi.mock("@/src/utils/api", () => ({diff --git a/web/src/features/feature-previews/components/FeaturePreviewModal.tsx b/web/src/features/feature-previews/components/FeaturePreviewModal.tsxindex a35b9696ea..de637be982 100644--- a/web/src/features/feature-previews/components/FeaturePreviewModal.tsx+++ b/web/src/features/feature-previews/components/FeaturePreviewModal.tsx@@ -16,7 +16,8 @@ import { cn } from "@/src/utils/tailwind";import {featurePreviewLabels,type PersonalFeaturePreviewFlag,-} from "@/src/features/feature-flags";+} from "@/src/features/feature-flags/available-flags";+import modernSessionDarkIllustration from "../assets/modern-session-dark.svg";import modernSessionLightIllustration from "../assets/modern-session-light.svg";diff --git a/web/src/features/feedback/server/FeedbackService.ts b/web/src/features/feedback/server/FeedbackService.tsindex 53843627a7..863144af32 100644--- a/web/src/features/feedback/server/FeedbackService.ts+++ b/web/src/features/feedback/server/FeedbackService.ts@@ -11,11 +11,11 @@ import {recordIncrement,} from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";-import {- RateLimitService,- type PostFeedbackBodyType,- type PostFeedbackResponseType,-} from "@/src/features/public-api/server";+import { RateLimitService } from "@/src/features/public-api/server/RateLimitService";+import type {+ PostFeedbackBodyType,+ PostFeedbackResponseType,+} from "@/src/features/public-api/types/feedback";export type FeedbackSource = "langfuse-mcp" | "public-api";diff --git a/web/src/features/feedback/server/feedbackHandler.ts b/web/src/features/feedback/server/feedbackHandler.tsindex 8a967c6042..ad967ccd45 100644--- a/web/src/features/feedback/server/feedbackHandler.ts+++ b/web/src/features/feedback/server/feedbackHandler.ts@@ -1,5 +1,5 @@import { runFeedbackCorsMiddleware } from "@/src/features/feedback/server/corsMiddleware";-import { sendToSlack } from "@/src/features/slack/server";+import { sendToSlack } from "@/src/features/slack/server/slack-webhook";import { type NextApiRequest, type NextApiResponse } from "next";import { logger } from "@langfuse/shared/src/server";diff --git a/web/src/features/feedback/server/index.ts b/web/src/features/feedback/server/index.tsdeleted file mode 100644index a5bcc9d224..0000000000--- a/web/src/features/feedback/server/index.ts+++ /dev/null@@ -1,6 +0,0 @@-// The feedback feature's server surface (RFC rule 9, amended): the-// product-feedback helpers MCP already imported by file path.-export {- isProductFeedbackAvailable,- submitFeedback,-} from "@/src/features/feedback/server/FeedbackService";diff --git a/web/src/features/filters/components/filter-builder.clienttest.tsx b/web/src/features/filters/components/filter-builder.clienttest.tsxindex 76c9166dea..6805c3db63 100644--- a/web/src/features/filters/components/filter-builder.clienttest.tsx+++ b/web/src/features/filters/components/filter-builder.clienttest.tsx@@ -13,7 +13,7 @@ vi.mock("@/src/features/projects/hooks", () => ({vi.mock("@/src/features/organizations/hooks", () => ({useLangfuseCloudRegion: () => ({ isLangfuseCloud: false }),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));vi.mock("@/src/utils/api", () => ({diff --git a/web/src/features/filters/components/filter-builder.tsx b/web/src/features/filters/components/filter-builder.tsxindex a2c4b1980f..1593c1e9fc 100644--- a/web/src/features/filters/components/filter-builder.tsx+++ b/web/src/features/filters/components/filter-builder.tsx@@ -61,7 +61,7 @@ import {import { cn } from "@/src/utils/tailwind";import { CompactConnectorRow } from "@/src/features/filters/components/CompactConnectorRow";import { CompactPickerButton } from "@/src/features/filters/components/CompactPickerButton";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {InputCommand,InputCommandEmpty,@@ -70,11 +70,9 @@ import {InputCommandItem,InputCommandList,} from "@/src/components/ui/input-command";-import { useQueryProject } from "@/src/features/projects";-import {- useLangfuseCloudRegion,- openAIFeaturesSettings,-} from "@/src/features/organizations";+import { useQueryProject } from "@/src/features/projects/hooks";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { openAIFeaturesSettings } from "@/src/features/organizations/components/AIFeaturesDisabledNotice";/*** Extended ColumnDefinition with optional alert for UI display.diff --git a/web/src/features/filters/config/scores-config.clienttest.ts b/web/src/features/filters/config/scores-config.clienttest.tsindex 365c7c5bdd..e56e10f3d3 100644--- a/web/src/features/filters/config/scores-config.clienttest.ts+++ b/web/src/features/filters/config/scores-config.clienttest.ts@@ -4,7 +4,7 @@ import { getScoreFilterConfig, observationScopeFilter } from "./scores-config";import { decodeAndNormalizeFilters } from "../hooks/useSidebarFilterState";import { encodeFiltersGeneric, type FilterState } from "@langfuse/shared";import { scoresFieldRegistry } from "@/src/features/scores/constants/scoresSearchRegistry";-import { planCommit } from "@/src/features/search-bar";+import { planCommit } from "@/src/features/search-bar/lib/commit";describe("getScoreFilterConfig", () => {it("keeps the evaluator-test filter when opening a score URL and editing its search pill", () => {diff --git a/web/src/features/filters/config/scores-config.ts b/web/src/features/filters/config/scores-config.tsindex c203f19068..8358d79fc9 100644--- a/web/src/features/filters/config/scores-config.ts+++ b/web/src/features/filters/config/scores-config.ts@@ -1,7 +1,6 @@-import { scoresTableCols } from "@/src/server/api/definitions/scoresTable";+import { scoresTableCols, type FilterState } from "@langfuse/shared";import type { FilterConfig } from "@/src/features/filters/lib/filter-config";import type { ColumnToBackendKeyMap } from "@/src/features/filters/lib/filter-transform";-import { type FilterState } from "@langfuse/shared";// Maps frontend column IDs to backend-expected column IDs// Frontend uses "tags" but backend CH mapping expects "trace_tags" for trace tags on scores tablediff --git a/web/src/features/filters/config/tracingSearchRegistry.clienttest.ts b/web/src/features/filters/config/tracingSearchRegistry.clienttest.tsindex 8010ffa566..ef495533b4 100644--- a/web/src/features/filters/config/tracingSearchRegistry.clienttest.ts+++ b/web/src/features/filters/config/tracingSearchRegistry.clienttest.ts@@ -2,12 +2,10 @@import { describe, expect, it } from "vitest";import type { FilterState } from "@langfuse/shared";-import {- planCommit,- filterStateToQueryText,- runSearchBarInvariants,- validateQuery,-} from "@/src/features/search-bar";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";+import { runSearchBarInvariants } from "@/src/features/search-bar/lib/searchBarInvariants";+import { validateQuery } from "@/src/features/search-bar/lib/validate";import { getTraceFilterConfig } from "./traces-config";import { getObservationsFilterConfig } from "./observations-config";diff --git a/web/src/features/filters/filter-integration.clienttest.ts b/web/src/features/filters/filter-integration.clienttest.tsindex eec433795d..01b3ecc9c1 100644--- a/web/src/features/filters/filter-integration.clienttest.ts+++ b/web/src/features/filters/filter-integration.clienttest.ts@@ -25,7 +25,7 @@ import {sessionEventsFilterConfig,sessionFilterConfig,} from "./config/sessions-config";-import { observationEventsFilterConfig } from "@/src/features/events";+import { observationEventsFilterConfig } from "@/src/features/events/config/filter-config";import {decodeAndNormalizeFilters,resolveCheckboxOperator,@@ -33,7 +33,7 @@ import {import {SESSION_DETAIL_SYSTEM_PRESETS,getSessionDetailPresetToApply,-} from "@/src/features/sessions";+} from "@/src/features/sessions/session-detail-presets";import {buildManagedEnvironmentPolicyConfig,buildImplicitEnvironmentFilter,@@ -41,11 +41,9 @@ import {canonicalizeExplicitEnvironmentFilters,toSearchBarEnvironmentFilters,} from "./lib/managedEnvironmentPolicy";-import {- astToFilterState,- filterStateToQueryText,- validateQuery,-} from "@/src/features/search-bar";+import { astToFilterState } from "@/src/features/search-bar/lib/adapter";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";+import { validateQuery } from "@/src/features/search-bar/lib/validate";// Helper to simulate complete URL flowfunction simulateUrlFlow(filters: FilterState): FilterState {diff --git a/web/src/features/filters/hooks/useFilterState.ts b/web/src/features/filters/hooks/useFilterState.tsindex ad5724b1da..5665e64a69 100644--- a/web/src/features/filters/hooks/useFilterState.ts+++ b/web/src/features/filters/hooks/useFilterState.ts@@ -15,8 +15,9 @@ import {splitOnUnescapedPipe,unescapePipeInValue,normalizeLegacySessionPositionInTraceKey,+ scoresTableCols,} from "@langfuse/shared";-import { scoresTableCols } from "@/src/server/api/definitions/scoresTable";+import {useQueryParam,encodeDelimitedArray,diff --git a/web/src/features/filters/hooks/useSidebarFilterState.tsx b/web/src/features/filters/hooks/useSidebarFilterState.tsxindex a4e55bf093..7cf327b937 100644--- a/web/src/features/filters/hooks/useSidebarFilterState.tsx+++ b/web/src/features/filters/hooks/useSidebarFilterState.tsx@@ -63,7 +63,7 @@ import {// Re-exported so existing consumers (tests, session view) keep their path.export { resolveCheckboxOperator } from "../lib/sidebar-filter-actions";import type { PeekTableStateContextValue } from "@/src/components/table/peek/contexts/PeekTableStateProvider";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";/*** Decodes filters from URL query string and normalizes display names to column IDs.diff --git a/web/src/features/filters/index.ts b/web/src/features/filters/index.tsdeleted file mode 100644index 0ca76a62e6..0000000000--- a/web/src/features/filters/index.ts+++ /dev/null@@ -1,82 +0,0 @@-// The filters feature's public surface (RFC rule 8). Named re-exports only —-// the filter builders, per-table filter configs and filter-state hooks other-// features already imported by file path.-//-// experiments' table filter-config stays on the deep path: filters' own-// useFilterState imports it, so routing it here would close a runtime cycle.-// events/config/filter-config stays on the deep path for the same reason-// against users-config.-export { CompactConnectorRow } from "@/src/features/filters/components/CompactConnectorRow";-export { CompactPickerButton } from "@/src/features/filters/components/CompactPickerButton";-export { FilterToken } from "@/src/features/filters/components/FilterToken";-export {- InlineFilterBuilder,- InlineFilterState,- PopoverFilterBuilder,-} from "@/src/features/filters/components/filter-builder";-export { MultiSelect } from "@/src/features/filters/components/MultiSelect";-// eval-logs / evaluators / scores configs stay on the deep path: they import-// server table definitions (and Prisma enums via those), and re-exporting-// them here would make every consumer of this client door fail-// Vite/Storybook's `export * from "@prisma/client"` interop.-// users-config stays on the deep path: it imports events' filter-config, so-// routing it here would close a cycle through that module.-export {- getMonitorFilterConfig,- monitorFilterConfig,-} from "@/src/features/filters/config/monitors-config";-export {- OBSERVATION_COLUMN_TO_BACKEND_KEY,- getObservationsFilterConfig,- observationFilterConfig,-} from "@/src/features/filters/config/observations-config";-export type { ObservationsOmittableFilterColumn } from "@/src/features/filters/config/observations-config";-export { promptFilterConfig } from "@/src/features/filters/config/prompts-config";-export {- SESSION_COLUMN_TO_BACKEND_KEY,- getSessionFilterConfig,-} from "@/src/features/filters/config/sessions-config";-export type { SessionOmittableFilterColumn } from "@/src/features/filters/config/sessions-config";-export {- SESSIONS_FIELD_REGISTRY,- sessionsFieldRegistry,-} from "@/src/features/filters/config/sessionsSearchRegistry";-export {- getTraceFilterConfig,- traceFilterConfig,-} from "@/src/features/filters/config/traces-config";-export type { TraceOmittableFilterColumn } from "@/src/features/filters/config/traces-config";-export {- observationsFieldRegistry,- tracesFieldRegistry,-} from "@/src/features/filters/config/tracingSearchRegistry";-export {- LEGACY_USERS_FIELD_REGISTRY,- USERS_FIELD_REGISTRY,-} from "@/src/features/filters/config/usersSearchRegistry";-export { useColumnFilterState } from "@/src/features/filters/hooks/useColumnFilterState";-export { useQueryFilterState } from "@/src/features/filters/hooks/useFilterState";-export {- decodeAndNormalizeFilters,- resolveCheckboxOperator,- useSidebarFilterPresentation,- useSidebarFilterState,- useSidebarFilterStateCore,-} from "@/src/features/filters/hooks/useSidebarFilterState";-export type {- FacetOptions,- UseSidebarFilterStateOptions,-} from "@/src/features/filters/hooks/useSidebarFilterState";-export { omitFilterFacets } from "@/src/features/filters/lib/filter-config";-export type { FilterConfig } from "@/src/features/filters/lib/filter-config";-export {- normalizeFilterColumnNames,- normalizeSingleValueOptions,- transformFiltersForBackend,-} from "@/src/features/filters/lib/filter-transform";-export { sortOptionValues } from "@/src/features/filters/lib/option-sort";-export {- buildSidebarFilterQueryStorageKey,- buildSidebarFilterSessionContextId,- readPersistedSidebarFilterQuery,-} from "@/src/features/filters/lib/persistedSidebarFilterQuery";diff --git a/web/src/features/filters/lib/facet-display.ts b/web/src/features/filters/lib/facet-display.tsindex fee95e4a21..3bb4a5965f 100644--- a/web/src/features/filters/lib/facet-display.ts+++ b/web/src/features/filters/lib/facet-display.ts@@ -1,5 +1,5 @@import type { UIFilter } from "@/src/features/filters/hooks/useSidebarFilterState";-import { filterRank } from "@/src/features/search-bar";+import { filterRank } from "@/src/features/search-bar/lib/rank";// Pure display helpers for the faceted filter sidebar// (data-table-controls.tsx). No React, no state — unit-testable.diff --git a/web/src/features/filters/savedViewImplicitEnvironmentRegression.clienttest.tsx b/web/src/features/filters/savedViewImplicitEnvironmentRegression.clienttest.tsxindex 8aa1787ac5..21313ec900 100644--- a/web/src/features/filters/savedViewImplicitEnvironmentRegression.clienttest.tsx+++ b/web/src/features/filters/savedViewImplicitEnvironmentRegression.clienttest.tsx@@ -15,10 +15,8 @@ import { useState } from "react";import { useSidebarFilterState } from "./hooks/useSidebarFilterState";import type { FilterConfig } from "./lib/filter-config";import { useTableViewManager } from "../../components/table/table-view-presets/hooks/useTableViewManager";-import {- EVENTS_FIELD_REGISTRY,- filterStateToQueryText,-} from "@/src/features/search-bar";+import { EVENTS_FIELD_REGISTRY } from "@/src/features/search-bar/lib/fields";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";import {buildManagedEnvironmentPolicyConfig,toSearchBarEnvironmentFilters,diff --git a/web/src/features/folders/index.ts b/web/src/features/folders/index.tsdeleted file mode 100644index a871082efc..0000000000--- a/web/src/features/folders/index.ts+++ /dev/null@@ -1,9 +0,0 @@-// The folders feature's public client surface (RFC rule 8). Named-// re-exports only — breadcrumb helpers other features already imported-// by file path.-export { FolderBreadcrumb } from "@/src/features/folders/components/FolderBreadcrumb";-export { useFolderPagination } from "@/src/features/folders/hooks/useFolderPagination";-export {- buildFullPath,- createBreadcrumbItems,-} from "@/src/features/folders/utils";diff --git a/web/src/features/in-app-agent/components/ControlledInAppAgentWindow.tsx b/web/src/features/in-app-agent/components/ControlledInAppAgentWindow.tsxindex 2ea391b96f..22d35c87f4 100644--- a/web/src/features/in-app-agent/components/ControlledInAppAgentWindow.tsx+++ b/web/src/features/in-app-agent/components/ControlledInAppAgentWindow.tsx@@ -9,7 +9,7 @@ import {} from "./InAppAgentWindow";import { useInAppAiAgent } from "./InAppAiAgentProvider";import { InAppAgentInternalSessionMenu } from "./InAppAgentInternalSessionMenu";-import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";import { useSmoothStreamingMessages } from "./useSmoothStreamingMessages";import { getDrawerMessages } from "./utils/utils";import { getInAppAgentScreenContextDescription } from "@/src/features/in-app-agent/context";diff --git a/web/src/features/in-app-agent/components/InAppAgentDisabledDialog.tsx b/web/src/features/in-app-agent/components/InAppAgentDisabledDialog.tsxindex ff3f06385a..9520d84a9b 100644--- a/web/src/features/in-app-agent/components/InAppAgentDisabledDialog.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentDisabledDialog.tsx@@ -8,7 +8,7 @@ import {DialogHeader,DialogTitle,} from "@/src/components/ui/dialog";-import { AIFeaturesDisabledNotice } from "@/src/features/organizations";+import { AIFeaturesDisabledNotice } from "@/src/features/organizations/components/AIFeaturesDisabledNotice";export function InAppAgentDisabledDialog({open,diff --git a/web/src/features/in-app-agent/components/InAppAgentInternalSessionMenu.tsx b/web/src/features/in-app-agent/components/InAppAgentInternalSessionMenu.tsxindex 26d72deae8..499b6a1e34 100644--- a/web/src/features/in-app-agent/components/InAppAgentInternalSessionMenu.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentInternalSessionMenu.tsx@@ -7,7 +7,7 @@ import {type DropdownMenuItemDefinition,} from "@/src/components/design-system/DropdownMenu/DropdownMenu";import { Button } from "@/src/components/ui/button";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { copyTextToClipboard } from "@/src/utils/clipboard";diff --git a/web/src/features/in-app-agent/components/InAppAgentWindow.tsx b/web/src/features/in-app-agent/components/InAppAgentWindow.tsxindex 193a3cd9d7..c72b77069c 100644--- a/web/src/features/in-app-agent/components/InAppAgentWindow.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentWindow.tsx@@ -89,7 +89,7 @@ import {type InAppAgentQuickActionContext,type InAppAgentSubmitOptions,} from "@/src/features/in-app-agent/quickActions";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Tabs } from "@/src/components/design-system/Tabs/Tabs";import { HaloIcon } from "@/src/features/in-app-agent/components/HaloIcon";diff --git a/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx b/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsxindex a4467da464..f3cf36fbaa 100644--- a/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx+++ b/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx@@ -60,16 +60,16 @@ import {isInAppAgentRateLimited,type InAppAiAgentMessage,} from "@/src/features/in-app-agent/components/utils/utils";-import { useHasEntitlement } from "@/src/features/entitlements";-import { showErrorToast } from "@/src/features/notifications";-import { useQueryProjectOrOrganization } from "@/src/features/projects";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";import { api } from "@/src/utils/api";import {createInAppAgentScreenContext,createInAppAgentUserContext,} from "@/src/features/in-app-agent/context";import type { InAppAgentSubmitOptions } from "@/src/features/in-app-agent/quickActions";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { evaluateSetStateAction } from "@/src/utils/evaluate-set-state-action";import { InAppAgentDisabledDialog } from "@/src/features/in-app-agent/components/InAppAgentDisabledDialog";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/in-app-agent/index.ts b/web/src/features/in-app-agent/index.tsdeleted file mode 100644index f76aeb8c0b..0000000000--- a/web/src/features/in-app-agent/index.ts+++ /dev/null@@ -1,13 +0,0 @@-// The in-app-agent feature's public client surface (RFC rule 8). Named-// re-exports only — the provider and widget composer-// other features already imported by file path.-//-// inAppAgentRouter and server helpers stay off this door. ids, display,-// and watchFrames stay deep for server tests (rule 10).-export { InAppAgentWidgetComposer } from "@/src/features/in-app-agent/components/InAppAgentWidgetComposer";-export {- InAppAiAgentProvider,- useInAppAiAgent,- useIsInAppAgentLauncherVisible,- type InAppAgentEntryPoint,-} from "@/src/features/in-app-agent/components/InAppAiAgentProvider";diff --git a/web/src/features/in-app-agent/server/availability.ts b/web/src/features/in-app-agent/server/availability.tsindex 4bdd2dd457..c06880f192 100644--- a/web/src/features/in-app-agent/server/availability.ts+++ b/web/src/features/in-app-agent/server/availability.ts@@ -8,7 +8,7 @@ import {LANGFUSE_AI_MODEL_UNCONFIGURED_MESSAGE,} from "@langfuse/shared/in-app-agent/server/modelProvider";-import { hasEntitlement } from "@/src/features/entitlements/server";+import { hasEntitlement } from "@/src/features/entitlements/server/hasEntitlement";export async function assertInAppAgentAvailable({prisma,diff --git a/web/src/features/in-app-agent/server/rateLimit.ts b/web/src/features/in-app-agent/server/rateLimit.tsindex ed0f94a34b..2fe1513411 100644--- a/web/src/features/in-app-agent/server/rateLimit.ts+++ b/web/src/features/in-app-agent/server/rateLimit.ts@@ -8,8 +8,8 @@ import {} from "@langfuse/shared";import type { ApiAccessScope } from "@langfuse/shared/src/server";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";-import { RateLimitService } from "@/src/features/public-api/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";+import { RateLimitService } from "@/src/features/public-api/server/RateLimitService";type SessionUser = NonNullable<Session["user"]>;diff --git a/web/src/features/in-app-agent/server/router.ts b/web/src/features/in-app-agent/server/router.tsindex eb4ad726d2..b265b99251 100644--- a/web/src/features/in-app-agent/server/router.ts+++ b/web/src/features/in-app-agent/server/router.ts@@ -40,7 +40,7 @@ import {getInAppAgentApiAccessScope,} from "@/src/features/in-app-agent/server/rateLimit";import { assertInAppAgentRunCapacity } from "@/src/features/in-app-agent/server/runCapacity";-import { hasInternalAccess } from "@/src/features/feature-flags/server";+import { hasInternalAccess } from "@/src/features/feature-flags/utils";import {cancelBackgroundRun,decideBackgroundApproval,diff --git a/web/src/features/llm-api-key/index.ts b/web/src/features/llm-api-key/index.tsdeleted file mode 100644index 0494eba1ed..0000000000--- a/web/src/features/llm-api-key/index.ts+++ /dev/null@@ -1,6 +0,0 @@-export {- AuthMethod,- BedrockAuthMethodSchema,- type BedrockAuthMethod,-} from "@/src/features/llm-api-key/types";-export { getConnectionAvailableModels } from "@/src/features/llm-api-key/availableModels";diff --git a/web/src/features/llm-api-key/server/index.ts b/web/src/features/llm-api-key/server/index.tsdeleted file mode 100644index 078aa27aeb..0000000000--- a/web/src/features/llm-api-key/server/index.ts+++ /dev/null@@ -1 +0,0 @@-export { LlmConnectionService } from "./llmConnectionService";diff --git a/web/src/features/llm-api-key/server/llmConnectionService.ts b/web/src/features/llm-api-key/server/llmConnectionService.tsindex c578415ffa..c1671228ef 100644--- a/web/src/features/llm-api-key/server/llmConnectionService.ts+++ b/web/src/features/llm-api-key/server/llmConnectionService.ts@@ -1,4 +1,7 @@-import { auditLog, type AuditLogActor } from "@/src/features/audit-logs/server";+import {+ auditLog,+ type AuditLogActor,+} from "@/src/features/audit-logs/auditLog";import { env } from "@/src/env.mjs";import {AuthMethod,diff --git a/web/src/features/llm-api-key/server/organizationRouter.ts b/web/src/features/llm-api-key/server/organizationRouter.tsindex a399bcc8b0..072daf3c45 100644--- a/web/src/features/llm-api-key/server/organizationRouter.ts+++ b/web/src/features/llm-api-key/server/organizationRouter.ts@@ -1,7 +1,7 @@import { z } from "zod";import type { Session } from "next-auth";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import {CreateOrganizationLlmApiKey,UpdateOrganizationLlmApiKey,diff --git a/web/src/features/llm-api-key/server/router.ts b/web/src/features/llm-api-key/server/router.tsindex aaaa192655..42a68cbded 100644--- a/web/src/features/llm-api-key/server/router.ts+++ b/web/src/features/llm-api-key/server/router.ts@@ -3,7 +3,7 @@ import {CreateLlmApiKey,UpdateLlmApiKey,} from "@/src/features/llm-api-key/types";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/llm-schemas/index.ts b/web/src/features/llm-schemas/index.tsdeleted file mode 100644index 9b35164bd8..0000000000--- a/web/src/features/llm-schemas/index.ts+++ /dev/null@@ -1 +0,0 @@-export { LLMSchemaNameSchema } from "@/src/features/llm-schemas/validation";diff --git a/web/src/features/llm-schemas/server/router.ts b/web/src/features/llm-schemas/server/router.tsindex 69be2703ca..b6584ea052 100644--- a/web/src/features/llm-schemas/server/router.ts+++ b/web/src/features/llm-schemas/server/router.ts@@ -4,9 +4,9 @@ import {createTRPCRouter,protectedProjectProcedure,} from "@/src/server/api/trpc";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { TRPCError } from "@trpc/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { logger } from "@langfuse/shared/src/server";import {CreateLlmSchemaInput,diff --git a/web/src/features/llm-tools/index.ts b/web/src/features/llm-tools/index.tsdeleted file mode 100644index 3c1258bc1a..0000000000--- a/web/src/features/llm-tools/index.ts+++ /dev/null@@ -1 +0,0 @@-export { LLMToolNameSchema } from "@/src/features/llm-tools/validation";diff --git a/web/src/features/llm-tools/server/router.ts b/web/src/features/llm-tools/server/router.tsindex 54b7119b34..8fc3973aab 100644--- a/web/src/features/llm-tools/server/router.ts+++ b/web/src/features/llm-tools/server/router.ts@@ -4,9 +4,9 @@ import {createTRPCRouter,protectedProjectProcedure,} from "@/src/server/api/trpc";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { TRPCError } from "@trpc/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { logger } from "@langfuse/shared/src/server";import {CreateLlmToolInput,diff --git a/web/src/features/mcp/core/define-tool.ts b/web/src/features/mcp/core/define-tool.tsindex c5de607ba4..3945c077e2 100644--- a/web/src/features/mcp/core/define-tool.ts+++ b/web/src/features/mcp/core/define-tool.ts@@ -6,7 +6,7 @@*/import { z } from "zod";-import type { ApiAction } from "@/src/features/public-api/server";+import type { ApiAction } from "@/src/features/public-api/server/enforceAuth";import type { ServerContext } from "../types";/**diff --git a/web/src/features/mcp/core/run-mcp-tool.ts b/web/src/features/mcp/core/run-mcp-tool.tsindex 0a045bf27d..7164815b18 100644--- a/web/src/features/mcp/core/run-mcp-tool.ts+++ b/web/src/features/mcp/core/run-mcp-tool.ts@@ -7,7 +7,7 @@ import {import { SpanKind, type Span } from "@opentelemetry/api";import { ZodError } from "zod";-import { StructuredPublicApiError } from "@/src/features/public-api";+import { StructuredPublicApiError } from "@/src/features/public-api/types/structuredPublicApiError";import { isUserInputError } from "./errors";import type { ServerContext } from "../types";diff --git a/web/src/features/mcp/server/annotationQueues/schema.ts b/web/src/features/mcp/server/annotationQueues/schema.tsindex 0f52268ad3..2faa04a3b9 100644--- a/web/src/features/mcp/server/annotationQueues/schema.ts+++ b/web/src/features/mcp/server/annotationQueues/schema.ts@@ -6,7 +6,7 @@ import {DeleteAnnotationQueueAssignmentBody,GetAnnotationQueueItemByIdQuery,UpdateAnnotationQueueItemBody,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/annotation-queues";export const CreateAnnotationQueueItemToolSchema = z.object({diff --git a/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueue.ts b/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueue.tsindex 6cef4e223b..c97d5b6ed3 100644--- a/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueue.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueue.ts@@ -1,8 +1,8 @@-import { createAnnotationQueueForApi } from "@/src/features/annotation-queues/server";+import { createAnnotationQueueForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";import {CreateAnnotationQueueBody,CreateAnnotationQueueResponse,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/annotation-queues";import { defineTool } from "../../../core/define-tool";import { buildAnnotationQueueUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueAssignment.ts b/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueAssignment.tsindex d0926b4345..e94e21ef1e 100644--- a/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueAssignment.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueAssignment.ts@@ -1,5 +1,5 @@-import { createAnnotationQueueAssignmentForApi } from "@/src/features/annotation-queues/server";-import { CreateAnnotationQueueAssignmentResponse } from "@/src/features/public-api/server";+import { createAnnotationQueueAssignmentForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";+import { CreateAnnotationQueueAssignmentResponse } from "@/src/features/public-api/types/annotation-queues";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";import { CreateAnnotationQueueAssignmentToolSchema } from "../schema";diff --git a/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueItem.ts b/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueItem.tsindex 53c452ad46..f746cf7e60 100644--- a/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueItem.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/createAnnotationQueueItem.ts@@ -1,5 +1,5 @@-import { createAnnotationQueueItemForApi } from "@/src/features/annotation-queues/server";-import { CreateAnnotationQueueItemResponse } from "@/src/features/public-api/server";+import { createAnnotationQueueItemForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";+import { CreateAnnotationQueueItemResponse } from "@/src/features/public-api/types/annotation-queues";import { defineTool } from "../../../core/define-tool";import { buildAnnotationQueueItemUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueAssignment.ts b/web/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueAssignment.tsindex bf8bc28850..3edd6ae803 100644--- a/web/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueAssignment.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueAssignment.ts@@ -1,5 +1,5 @@-import { deleteAnnotationQueueAssignment } from "@/src/features/annotation-queues/server";-import { DeleteAnnotationQueueAssignmentResponse } from "@/src/features/public-api/server";+import { deleteAnnotationQueueAssignment } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";+import { DeleteAnnotationQueueAssignmentResponse } from "@/src/features/public-api/types/annotation-queues";import { LangfuseNotFoundError, Prisma } from "@langfuse/shared";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueItem.ts b/web/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueItem.tsindex 1254a700a2..42e782dc0a 100644--- a/web/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueItem.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/deleteAnnotationQueueItem.ts@@ -1,8 +1,8 @@-import { deleteAnnotationQueueItemForApi } from "@/src/features/annotation-queues/server";+import { deleteAnnotationQueueItemForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";import {DeleteAnnotationQueueItemQuery,DeleteAnnotationQueueItemResponse,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/annotation-queues";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/annotationQueues/tools/getAnnotationQueue.ts b/web/src/features/mcp/server/annotationQueues/tools/getAnnotationQueue.tsindex 4d1324972c..c9e4ffce37 100644--- a/web/src/features/mcp/server/annotationQueues/tools/getAnnotationQueue.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/getAnnotationQueue.ts@@ -1,8 +1,8 @@import {GetAnnotationQueueByIdQuery,GetAnnotationQueueByIdResponse,-} from "@/src/features/public-api/server";-import { getAnnotationQueueForApi } from "@/src/features/annotation-queues/server";+} from "@/src/features/public-api/types/annotation-queues";+import { getAnnotationQueueForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";import { defineTool } from "../../../core/define-tool";import { buildAnnotationQueueUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/annotationQueues/tools/getAnnotationQueueItem.ts b/web/src/features/mcp/server/annotationQueues/tools/getAnnotationQueueItem.tsindex 60993cb1b9..837af963c4 100644--- a/web/src/features/mcp/server/annotationQueues/tools/getAnnotationQueueItem.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/getAnnotationQueueItem.ts@@ -1,8 +1,8 @@import {GetAnnotationQueueItemByIdQuery,GetAnnotationQueueItemByIdResponse,-} from "@/src/features/public-api/server";-import { getAnnotationQueueItemForApi } from "@/src/features/annotation-queues/server";+} from "@/src/features/public-api/types/annotation-queues";+import { getAnnotationQueueItemForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";import { defineTool } from "../../../core/define-tool";import { buildAnnotationQueueItemUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/annotationQueues/tools/index.ts b/web/src/features/mcp/server/annotationQueues/tools/index.tsdeleted file mode 100644index 35e71625bb..0000000000--- a/web/src/features/mcp/server/annotationQueues/tools/index.ts+++ /dev/null@@ -1,10 +0,0 @@-export * from "./createAnnotationQueue";-export * from "./createAnnotationQueueAssignment";-export * from "./createAnnotationQueueItem";-export * from "./deleteAnnotationQueueAssignment";-export * from "./deleteAnnotationQueueItem";-export * from "./getAnnotationQueue";-export * from "./getAnnotationQueueItem";-export * from "./listAnnotationQueueItems";-export * from "./listAnnotationQueues";-export * from "./updateAnnotationQueueItem";diff --git a/web/src/features/mcp/server/annotationQueues/tools/listAnnotationQueueItems.ts b/web/src/features/mcp/server/annotationQueues/tools/listAnnotationQueueItems.tsindex 4510ed3e92..218152e35f 100644--- a/web/src/features/mcp/server/annotationQueues/tools/listAnnotationQueueItems.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/listAnnotationQueueItems.ts@@ -1,8 +1,8 @@import {GetAnnotationQueueItemsQuery,GetAnnotationQueueItemsResponse,-} from "@/src/features/public-api/server";-import { listAnnotationQueueItemsForApi } from "@/src/features/annotation-queues/server";+} from "@/src/features/public-api/types/annotation-queues";+import { listAnnotationQueueItemsForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";import { defineTool } from "../../../core/define-tool";import { buildAnnotationQueueItemUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/annotationQueues/tools/listAnnotationQueues.ts b/web/src/features/mcp/server/annotationQueues/tools/listAnnotationQueues.tsindex 16ab50c371..3c55703d8d 100644--- a/web/src/features/mcp/server/annotationQueues/tools/listAnnotationQueues.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/listAnnotationQueues.ts@@ -1,8 +1,8 @@import {GetAnnotationQueuesQuery,GetAnnotationQueuesResponse,-} from "@/src/features/public-api/server";-import { listAnnotationQueuesForApi } from "@/src/features/annotation-queues/server";+} from "@/src/features/public-api/types/annotation-queues";+import { listAnnotationQueuesForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";import { defineTool } from "../../../core/define-tool";import { buildAnnotationQueueUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/annotationQueues/tools/updateAnnotationQueueItem.ts b/web/src/features/mcp/server/annotationQueues/tools/updateAnnotationQueueItem.tsindex 766f4849fd..4c669893c2 100644--- a/web/src/features/mcp/server/annotationQueues/tools/updateAnnotationQueueItem.ts+++ b/web/src/features/mcp/server/annotationQueues/tools/updateAnnotationQueueItem.ts@@ -1,5 +1,5 @@-import { updateAnnotationQueueItemForApi } from "@/src/features/annotation-queues/server";-import { UpdateAnnotationQueueItemResponse } from "@/src/features/public-api/server";+import { updateAnnotationQueueItemForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";+import { UpdateAnnotationQueueItemResponse } from "@/src/features/public-api/types/annotation-queues";import { defineTool } from "../../../core/define-tool";import { buildAnnotationQueueItemUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/comments/tools/createComment.ts b/web/src/features/mcp/server/comments/tools/createComment.tsindex 5066f6cbef..92854de64a 100644--- a/web/src/features/mcp/server/comments/tools/createComment.ts+++ b/web/src/features/mcp/server/comments/tools/createComment.ts@@ -1,10 +1,10 @@import { CommentObjectType } from "@langfuse/shared";import { z } from "zod";-import { createCommentForApi } from "@/src/features/comments/server";+import { createCommentForApi } from "@/src/features/comments/server/publicCommentService";import {PostCommentsV1Body,PostCommentsV1Response,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/comments";import { defineTool } from "../../../core/define-tool";import { buildCommentObjectUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/comments/tools/getComment.ts b/web/src/features/mcp/server/comments/tools/getComment.tsindex 18dff68c50..530e9b594a 100644--- a/web/src/features/mcp/server/comments/tools/getComment.ts+++ b/web/src/features/mcp/server/comments/tools/getComment.ts@@ -1,8 +1,8 @@-import { getCommentForApi } from "@/src/features/comments/server";+import { getCommentForApi } from "@/src/features/comments/server/publicCommentService";import {GetCommentV1Query,GetCommentV1Response,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/comments";import { defineTool } from "../../../core/define-tool";import { buildCommentObjectUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/comments/tools/index.ts b/web/src/features/mcp/server/comments/tools/index.tsdeleted file mode 100644index 81e094292b..0000000000--- a/web/src/features/mcp/server/comments/tools/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from "./createComment";-export * from "./getComment";-export * from "./listComments";diff --git a/web/src/features/mcp/server/comments/tools/listComments.ts b/web/src/features/mcp/server/comments/tools/listComments.tsindex e45898dc6f..5c70d14245 100644--- a/web/src/features/mcp/server/comments/tools/listComments.ts+++ b/web/src/features/mcp/server/comments/tools/listComments.ts@@ -1,10 +1,10 @@import { CommentObjectType, publicApiPaginationZod } from "@langfuse/shared";import { z } from "zod";-import { listCommentsForApi } from "@/src/features/comments/server";+import { listCommentsForApi } from "@/src/features/comments/server/publicCommentService";import {GetCommentsV1Query,GetCommentsV1Response,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/comments";import { defineTool } from "../../../core/define-tool";import { buildCommentObjectUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/dashboardWidgets/tools/createDashboardWidget.ts b/web/src/features/mcp/server/dashboardWidgets/tools/createDashboardWidget.tsindex 6c55c52e0a..c5e4bd6cf4 100644--- a/web/src/features/mcp/server/dashboardWidgets/tools/createDashboardWidget.ts+++ b/web/src/features/mcp/server/dashboardWidgets/tools/createDashboardWidget.ts@@ -6,13 +6,13 @@ import {import { metricAggregations } from "@langfuse/shared/query";import { defineTool } from "@/src/features/mcp/core/define-tool";import { runMcpTool } from "@/src/features/mcp/core/run-mcp-tool";-import { createPublicDashboardWidget } from "@/src/features/widgets/server";-import { getWidgetImportFilterConfig } from "@/src/features/dashboard/server";-import { StructuredPublicApiError } from "@/src/features/public-api";+import { createPublicDashboardWidget } from "@/src/features/widgets/server/public-dashboard-widget-service";+import { getWidgetImportFilterConfig } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";+import { StructuredPublicApiError } from "@/src/features/public-api/types/structuredPublicApiError";import {PostUnstableDashboardWidgetBody,PostUnstableDashboardWidgetView,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/unstable-dashboard-widgets";import { buildDashboardWidgetUrl } from "@langfuse/shared/src/server";export const DashboardWidgetFilterBaseSchema = zdiff --git a/web/src/features/mcp/server/dashboardWidgets/tools/dashboardCrud.ts b/web/src/features/mcp/server/dashboardWidgets/tools/dashboardCrud.tsindex ba57ed478b..ae1465506b 100644--- a/web/src/features/mcp/server/dashboardWidgets/tools/dashboardCrud.ts+++ b/web/src/features/mcp/server/dashboardWidgets/tools/dashboardCrud.ts@@ -15,17 +15,19 @@ import {GetUnstableDashboardWidgetsQuery,DashboardWidgetIdQuery,PatchUnstableDashboardWidgetBody,+} from "@/src/features/public-api/types/unstable-dashboard-widgets";+import {DashboardIdQuery,GetUnstableDashboardsQuery,PatchUnstableDashboardBody,PostUnstableDashboardBody,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/unstable-dashboards";import {deletePublicDashboardWidget,getPublicDashboardWidget,listPublicDashboardWidgets,updatePublicDashboardWidget,-} from "@/src/features/widgets/server";+} from "@/src/features/widgets/server/public-dashboard-widget-service";import {addPublicDashboardPlacement,createPublicDashboard,@@ -35,7 +37,7 @@ import {listPublicDashboards,updatePublicDashboard,updatePublicDashboardPlacement,-} from "@/src/features/dashboard/server";+} from "@/src/features/dashboard/server/public-dashboard-service";const auditScope = (context: { orgId: string; apiKeyId: string }) => ({orgId: context.orgId,diff --git a/web/src/features/mcp/server/datasets/schema.ts b/web/src/features/mcp/server/datasets/schema.tsindex 2632048f04..e90ce119bd 100644--- a/web/src/features/mcp/server/datasets/schema.ts+++ b/web/src/features/mcp/server/datasets/schema.ts@@ -1,5 +1,5 @@import { z } from "zod";-import { publicApiIdSchema } from "@/src/features/public-api/server";+import { publicApiIdSchema } from "@/src/features/public-api/types/datasets";const paginationSchema = {page: z.number().int().positive().default(1),diff --git a/web/src/features/mcp/server/datasets/tools/batchUpsertDatasetItems.ts b/web/src/features/mcp/server/datasets/tools/batchUpsertDatasetItems.tsindex c6ee312bfc..63e736cdd6 100644--- a/web/src/features/mcp/server/datasets/tools/batchUpsertDatasetItems.ts+++ b/web/src/features/mcp/server/datasets/tools/batchUpsertDatasetItems.ts@@ -1,5 +1,5 @@-import { createDatasetItemForApi } from "@/src/features/datasets/server";-import { PostDatasetItemsV1Response } from "@/src/features/public-api/server";+import { createDatasetItemForApi } from "@/src/features/datasets/server/publicDatasetService";+import { PostDatasetItemsV1Response } from "@/src/features/public-api/types/datasets";import { buildDatasetItemUrl } from "@langfuse/shared/src/server";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/datasets/tools/createDatasetRunItem.ts b/web/src/features/mcp/server/datasets/tools/createDatasetRunItem.tsindex 3da52e845a..59b0c3763f 100644--- a/web/src/features/mcp/server/datasets/tools/createDatasetRunItem.ts+++ b/web/src/features/mcp/server/datasets/tools/createDatasetRunItem.ts@@ -1,7 +1,7 @@import { isoDateTime } from "@langfuse/shared";import { z } from "zod";-import { PostDatasetRunItemsV1Body } from "@/src/features/public-api/server";-import { createDatasetRunItemForApi } from "@/src/features/datasets/server";+import { PostDatasetRunItemsV1Body } from "@/src/features/public-api/types/datasets";+import { createDatasetRunItemForApi } from "@/src/features/datasets/server/publicDatasetService";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";import { getMcpPublicApiAuth } from "../../publicApi";diff --git a/web/src/features/mcp/server/datasets/tools/deleteDatasetItem.ts b/web/src/features/mcp/server/datasets/tools/deleteDatasetItem.tsindex 114bdcbe23..5a6c7f0d46 100644--- a/web/src/features/mcp/server/datasets/tools/deleteDatasetItem.ts+++ b/web/src/features/mcp/server/datasets/tools/deleteDatasetItem.ts@@ -1,8 +1,8 @@-import { deleteDatasetItemForApi } from "@/src/features/datasets/server";+import { deleteDatasetItemForApi } from "@/src/features/datasets/server/publicDatasetService";import {DeleteDatasetItemV1Query,DeleteDatasetItemV1Response,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/datasets";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/datasets/tools/deleteDatasetRun.ts b/web/src/features/mcp/server/datasets/tools/deleteDatasetRun.tsindex 6d51f9ebf4..88e7ac4136 100644--- a/web/src/features/mcp/server/datasets/tools/deleteDatasetRun.ts+++ b/web/src/features/mcp/server/datasets/tools/deleteDatasetRun.ts@@ -1,5 +1,5 @@-import { deleteDatasetRunByIdForApi } from "@/src/features/datasets/server";-import { DeleteDatasetRunV1Response } from "@/src/features/public-api/server";+import { deleteDatasetRunByIdForApi } from "@/src/features/datasets/server/publicDatasetService";+import { DeleteDatasetRunV1Response } from "@/src/features/public-api/types/datasets";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";import { rejectDatasetRunToolsInEventsOnlyMode } from "../events-only-guard";diff --git a/web/src/features/mcp/server/datasets/tools/getDataset.ts b/web/src/features/mcp/server/datasets/tools/getDataset.tsindex 2fe4a6b009..edb22cb38f 100644--- a/web/src/features/mcp/server/datasets/tools/getDataset.ts+++ b/web/src/features/mcp/server/datasets/tools/getDataset.ts@@ -1,8 +1,8 @@-import { GetDatasetV2Response } from "@/src/features/public-api/server";+import { GetDatasetV2Response } from "@/src/features/public-api/types/datasets";import { defineTool } from "../../../core/define-tool";import { buildDatasetUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";-import { getDatasetByIdForApi } from "@/src/features/datasets/server";+import { getDatasetByIdForApi } from "@/src/features/datasets/server/publicDatasetService";import { GetDatasetMcpInput } from "../schema";export const [getDatasetTool, handleGetDataset] = defineTool({diff --git a/web/src/features/mcp/server/datasets/tools/getDatasetItem.ts b/web/src/features/mcp/server/datasets/tools/getDatasetItem.tsindex 70dc5fb635..968fa9c10e 100644--- a/web/src/features/mcp/server/datasets/tools/getDatasetItem.ts+++ b/web/src/features/mcp/server/datasets/tools/getDatasetItem.ts@@ -1,8 +1,8 @@import {GetDatasetItemV1Query,GetDatasetItemV1Response,-} from "@/src/features/public-api/server";-import { getDatasetItemForApi } from "@/src/features/datasets/server";+} from "@/src/features/public-api/types/datasets";+import { getDatasetItemForApi } from "@/src/features/datasets/server/publicDatasetService";import { defineTool } from "../../../core/define-tool";import { buildDatasetItemUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/datasets/tools/getDatasetRun.ts b/web/src/features/mcp/server/datasets/tools/getDatasetRun.tsindex 49c3144a29..27da7d2a7c 100644--- a/web/src/features/mcp/server/datasets/tools/getDatasetRun.ts+++ b/web/src/features/mcp/server/datasets/tools/getDatasetRun.ts@@ -1,5 +1,5 @@-import { GetDatasetRunV1Response } from "@/src/features/public-api/server";-import { getDatasetRunByIdForApi } from "@/src/features/datasets/server";+import { GetDatasetRunV1Response } from "@/src/features/public-api/types/datasets";+import { getDatasetRunByIdForApi } from "@/src/features/datasets/server/publicDatasetService";import { defineTool } from "../../../core/define-tool";import { buildDatasetRunUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/datasets/tools/index.ts b/web/src/features/mcp/server/datasets/tools/index.tsdeleted file mode 100644index 92af6584a2..0000000000--- a/web/src/features/mcp/server/datasets/tools/index.ts+++ /dev/null@@ -1,13 +0,0 @@-export * from "./upsertDataset";-export * from "./upsertDatasetItem";-export * from "./batchUpsertDatasetItems";-export * from "./createDatasetRunItem";-export * from "./deleteDatasetItem";-export * from "./deleteDatasetRun";-export * from "./getDataset";-export * from "./getDatasetItem";-export * from "./getDatasetRun";-export * from "./listDatasetItems";-export * from "./listDatasetRunItems";-export * from "./listDatasetRuns";-export * from "./listDatasets";diff --git a/web/src/features/mcp/server/datasets/tools/listDatasetItems.ts b/web/src/features/mcp/server/datasets/tools/listDatasetItems.tsindex d32eff39b4..82b676f244 100644--- a/web/src/features/mcp/server/datasets/tools/listDatasetItems.ts+++ b/web/src/features/mcp/server/datasets/tools/listDatasetItems.ts@@ -1,5 +1,5 @@-import { GetDatasetItemsV1Response } from "@/src/features/public-api/server";-import { listDatasetItemsForApi } from "@/src/features/datasets/server";+import { GetDatasetItemsV1Response } from "@/src/features/public-api/types/datasets";+import { listDatasetItemsForApi } from "@/src/features/datasets/server/publicDatasetService";import { defineTool } from "../../../core/define-tool";import { buildDatasetItemUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/datasets/tools/listDatasetRunItems.ts b/web/src/features/mcp/server/datasets/tools/listDatasetRunItems.tsindex 49242e7bc4..2a670b412b 100644--- a/web/src/features/mcp/server/datasets/tools/listDatasetRunItems.ts+++ b/web/src/features/mcp/server/datasets/tools/listDatasetRunItems.ts@@ -1,5 +1,5 @@-import { listDatasetRunItemsByRunIdForApi } from "@/src/features/datasets/server";-import { GetDatasetRunItemsV1Response } from "@/src/features/public-api/server";+import { listDatasetRunItemsByRunIdForApi } from "@/src/features/datasets/server/publicDatasetService";+import { GetDatasetRunItemsV1Response } from "@/src/features/public-api/types/datasets";import { defineTool } from "../../../core/define-tool";import { buildDatasetRunUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/datasets/tools/listDatasetRuns.ts b/web/src/features/mcp/server/datasets/tools/listDatasetRuns.tsindex d1b8f7f6be..c9245dfb75 100644--- a/web/src/features/mcp/server/datasets/tools/listDatasetRuns.ts+++ b/web/src/features/mcp/server/datasets/tools/listDatasetRuns.ts@@ -1,5 +1,5 @@-import { GetDatasetRunsV1Response } from "@/src/features/public-api/server";-import { listDatasetRunsByDatasetIdForApi } from "@/src/features/datasets/server";+import { GetDatasetRunsV1Response } from "@/src/features/public-api/types/datasets";+import { listDatasetRunsByDatasetIdForApi } from "@/src/features/datasets/server/publicDatasetService";import { defineTool } from "../../../core/define-tool";import { buildDatasetRunUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/datasets/tools/listDatasets.ts b/web/src/features/mcp/server/datasets/tools/listDatasets.tsindex e8eb2716d5..6eec5caac8 100644--- a/web/src/features/mcp/server/datasets/tools/listDatasets.ts+++ b/web/src/features/mcp/server/datasets/tools/listDatasets.ts@@ -1,8 +1,8 @@-import { GetDatasetsV2Response } from "@/src/features/public-api/server";+import { GetDatasetsV2Response } from "@/src/features/public-api/types/datasets";import { defineTool } from "../../../core/define-tool";import { buildDatasetUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";-import { listDatasetsForApi } from "@/src/features/datasets/server";+import { listDatasetsForApi } from "@/src/features/datasets/server/publicDatasetService";import { GetDatasetsMcpInput } from "../schema";export const [listDatasetsTool, handleListDatasets] = defineTool({diff --git a/web/src/features/mcp/server/datasets/tools/upsertDataset.ts b/web/src/features/mcp/server/datasets/tools/upsertDataset.tsindex 7c3e286e50..d045f7ac75 100644--- a/web/src/features/mcp/server/datasets/tools/upsertDataset.ts+++ b/web/src/features/mcp/server/datasets/tools/upsertDataset.ts@@ -1,9 +1,9 @@import { z } from "zod";-import { createDatasetForApi } from "@/src/features/datasets/server";+import { createDatasetForApi } from "@/src/features/datasets/server/publicDatasetService";import {PostDatasetsV2Body,PostDatasetsV2Response,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/datasets";import {DatasetJSONSchema,buildDatasetUrl,diff --git a/web/src/features/mcp/server/datasets/tools/upsertDatasetItem.ts b/web/src/features/mcp/server/datasets/tools/upsertDatasetItem.tsindex 766914cadd..2db4752808 100644--- a/web/src/features/mcp/server/datasets/tools/upsertDatasetItem.ts+++ b/web/src/features/mcp/server/datasets/tools/upsertDatasetItem.ts@@ -1,5 +1,5 @@-import { createDatasetItemForApi } from "@/src/features/datasets/server";-import { PostDatasetItemsV1Response } from "@/src/features/public-api/server";+import { createDatasetItemForApi } from "@/src/features/datasets/server/publicDatasetService";+import { PostDatasetItemsV1Response } from "@/src/features/public-api/types/datasets";import { defineTool } from "../../../core/define-tool";import { buildDatasetItemUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/evals/batch-evaluation-service.ts b/web/src/features/mcp/server/evals/batch-evaluation-service.tsindex 5b660bcc40..f43a012cc9 100644--- a/web/src/features/mcp/server/evals/batch-evaluation-service.ts+++ b/web/src/features/mcp/server/evals/batch-evaluation-service.ts@@ -1,4 +1,4 @@-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { BatchEvaluationService } from "@/src/features/batch-actions/server/batchEvaluationService";import { ActionId } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";diff --git a/web/src/features/mcp/server/evals/evaluator-service.ts b/web/src/features/mcp/server/evals/evaluator-service.tsindex d5dca5c38e..f920c2d699 100644--- a/web/src/features/mcp/server/evals/evaluator-service.ts+++ b/web/src/features/mcp/server/evals/evaluator-service.ts@@ -1,4 +1,4 @@-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { EvaluatorService } from "@/src/features/evals/v2/server/evaluators/evaluatorService";import { prisma } from "@langfuse/shared/src/db";import type { ServerContext } from "../../types";diff --git a/web/src/features/mcp/server/evals/rule-schema.ts b/web/src/features/mcp/server/evals/rule-schema.tsindex 4b9273cbad..52f83a53d4 100644--- a/web/src/features/mcp/server/evals/rule-schema.ts+++ b/web/src/features/mcp/server/evals/rule-schema.ts@@ -12,7 +12,7 @@ import {ObservationPromptVariableMappingInput,PromptVariableMappingRead,PublicEvaluatorType,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/evaluation/publicEvalsContract";import { McpAdvancedFilterBaseSchema } from "../../core/filter-schema";export const McpEvaluatorType = z.enum([diff --git a/web/src/features/mcp/server/evals/rule-service.ts b/web/src/features/mcp/server/evals/rule-service.tsindex 9a27d7c6ca..161824db7f 100644--- a/web/src/features/mcp/server/evals/rule-service.ts+++ b/web/src/features/mcp/server/evals/rule-service.ts@@ -1,11 +1,11 @@-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { JOB_CONFIGURATION_AUDIT_LOG_RESOURCE_TYPE } from "@/src/features/evals/server/audit-log-resource-types";import {isPublicApiEvaluatorType,toApiReadMappings,toPublicEvaluatorType,toStoredMappingList,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/server/evaluation/evaluationAdapters";import { RuleService } from "@/src/features/evals/v2/server/rules/ruleService";import { EvalTemplateType, InvalidRequestError } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";diff --git a/web/src/features/mcp/server/evals/tools/listManagedEvaluatorTemplates.ts b/web/src/features/mcp/server/evals/tools/listManagedEvaluatorTemplates.tsindex 66c8688fe5..d2c49678a3 100644--- a/web/src/features/mcp/server/evals/tools/listManagedEvaluatorTemplates.ts+++ b/web/src/features/mcp/server/evals/tools/listManagedEvaluatorTemplates.ts@@ -1,7 +1,7 @@import { z } from "zod";import { EvalTemplateType } from "@langfuse/shared";-import { managedEvaluatorTemplateService } from "@/src/features/evals";+import { managedEvaluatorTemplateService } from "@/src/features/evals/v2/fns/templateGallery/managedEvaluatorTemplateService";import { defineTool } from "@/src/features/mcp/core/define-tool";import { runMcpTool } from "@/src/features/mcp/core/run-mcp-tool";diff --git a/web/src/features/mcp/server/experiments/index.ts b/web/src/features/mcp/server/experiments/index.tsindex 3700976af6..72338e1b88 100644--- a/web/src/features/mcp/server/experiments/index.ts+++ b/web/src/features/mcp/server/experiments/index.ts@@ -2,10 +2,12 @@ import { env } from "@/src/env.mjs";import type { McpFeatureModule } from "../registry";import {handleListExperimentItems,- handleListExperiments,listExperimentItemsTool,+} from "@/src/features/mcp/server/experiments/tools/listExperimentItems";+import {+ handleListExperiments,listExperimentsTool,-} from "./tools";+} from "@/src/features/mcp/server/experiments/tools/listExperiments";export const experimentsFeature = {name: "experiments",diff --git a/web/src/features/mcp/server/experiments/schema.ts b/web/src/features/mcp/server/experiments/schema.tsindex 53fe513b4c..df39559070 100644--- a/web/src/features/mcp/server/experiments/schema.ts+++ b/web/src/features/mcp/server/experiments/schema.ts@@ -5,7 +5,7 @@ import {GetExperimentItemsV1ParsedQueryBase,GetExperimentItemsV1ParsedQuery,GetExperimentsV1ParsedQuery,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/experiments";import { z } from "zod";import { McpAdvancedFilterBaseSchema } from "../../core/filter-schema";diff --git a/web/src/features/mcp/server/experiments/tools/index.ts b/web/src/features/mcp/server/experiments/tools/index.tsdeleted file mode 100644index 1a685bd2cd..0000000000--- a/web/src/features/mcp/server/experiments/tools/index.ts+++ /dev/null@@ -1,5 +0,0 @@-export { listExperimentsTool, handleListExperiments } from "./listExperiments";-export {- listExperimentItemsTool,- handleListExperimentItems,-} from "./listExperimentItems";diff --git a/web/src/features/mcp/server/experiments/tools/listExperimentItems.ts b/web/src/features/mcp/server/experiments/tools/listExperimentItems.tsindex 8a5c12e8f9..00bf9de43e 100644--- a/web/src/features/mcp/server/experiments/tools/listExperimentItems.ts+++ b/web/src/features/mcp/server/experiments/tools/listExperimentItems.ts@@ -1,5 +1,5 @@-import { listExperimentItemsForPublicApi } from "@/src/features/experiments/server";-import { GetExperimentItemsV1Response } from "@/src/features/public-api/server";+import { listExperimentItemsForPublicApi } from "@/src/features/experiments/server/public/service";+import { GetExperimentItemsV1Response } from "@/src/features/public-api/types/experiments";import { buildObservationUrl } from "@langfuse/shared/src/server";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";@@ -7,7 +7,7 @@ import {ListExperimentItemsBaseSchema,ListExperimentItemsInputSchema,} from "../schema";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export const [listExperimentItemsTool, handleListExperimentItems] = defineTool({name: "listExperimentItems",diff --git a/web/src/features/mcp/server/experiments/tools/listExperiments.ts b/web/src/features/mcp/server/experiments/tools/listExperiments.tsindex 45c1af9951..07f2f3ee52 100644--- a/web/src/features/mcp/server/experiments/tools/listExperiments.ts+++ b/web/src/features/mcp/server/experiments/tools/listExperiments.ts@@ -1,5 +1,5 @@-import { listExperimentsForPublicApi } from "@/src/features/experiments/server";-import { GetExperimentsV1Response } from "@/src/features/public-api/server";+import { listExperimentsForPublicApi } from "@/src/features/experiments/server/public/service";+import { GetExperimentsV1Response } from "@/src/features/public-api/types/experiments";import { buildExperimentUrl } from "@langfuse/shared/src/server";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";@@ -7,7 +7,7 @@ import {ListExperimentsBaseSchema,ListExperimentsInputSchema,} from "../schema";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export const [listExperimentsTool, handleListExperiments] = defineTool({name: "listExperiments",diff --git a/web/src/features/mcp/server/externalMediaStorage/index.ts b/web/src/features/mcp/server/externalMediaStorage/index.tsindex 81356302b5..67f3e16ba0 100644--- a/web/src/features/mcp/server/externalMediaStorage/index.ts+++ b/web/src/features/mcp/server/externalMediaStorage/index.ts@@ -1,6 +1,6 @@import { prisma } from "@langfuse/shared/src/db";-import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server";+import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server/service";import { type McpFeatureModule } from "@/src/features/mcp/server/registry";import {diff --git a/web/src/features/mcp/server/externalMediaStorage/tools.ts b/web/src/features/mcp/server/externalMediaStorage/tools.tsindex bde5811504..3f55ec632b 100644--- a/web/src/features/mcp/server/externalMediaStorage/tools.ts+++ b/web/src/features/mcp/server/externalMediaStorage/tools.ts@@ -1,7 +1,7 @@import { prisma } from "@langfuse/shared/src/db";import { z } from "zod";-import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server";+import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server/service";import { externalMediaStorageFormSchema } from "@/src/features/external-media-storage/types";import { defineTool } from "@/src/features/mcp/core/define-tool";import { runMcpTool } from "@/src/features/mcp/core/run-mcp-tool";diff --git a/web/src/features/mcp/server/feedback/index.ts b/web/src/features/mcp/server/feedback/index.tsindex 46d46c1379..d9835075d4 100644--- a/web/src/features/mcp/server/feedback/index.ts+++ b/web/src/features/mcp/server/feedback/index.ts@@ -1,4 +1,4 @@-import { isProductFeedbackAvailable } from "@/src/features/feedback/server";+import { isProductFeedbackAvailable } from "@/src/features/feedback/server/FeedbackService";import type { McpFeatureModule } from "../registry";import {handleSubmitFeedback,diff --git a/web/src/features/mcp/server/feedback/tools/submitFeedback.ts b/web/src/features/mcp/server/feedback/tools/submitFeedback.tsindex 7bbd1ba494..ade359918d 100644--- a/web/src/features/mcp/server/feedback/tools/submitFeedback.ts+++ b/web/src/features/mcp/server/feedback/tools/submitFeedback.ts@@ -1,5 +1,5 @@-import { submitFeedback } from "@/src/features/feedback/server";-import { PostFeedbackBody } from "@/src/features/public-api/server";+import { submitFeedback } from "@/src/features/feedback/server/FeedbackService";+import { PostFeedbackBody } from "@/src/features/public-api/types/feedback";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/health/tools/getHealth.ts b/web/src/features/mcp/server/health/tools/getHealth.tsindex dc49a0c9b0..2578e03fb8 100644--- a/web/src/features/mcp/server/health/tools/getHealth.ts+++ b/web/src/features/mcp/server/health/tools/getHealth.ts@@ -1,8 +1,6 @@import { z } from "zod";-import {- runHealthCheck,- __dangerouslySkipAuthz,-} from "@/src/features/public-api/server";+import { runHealthCheck } from "@/src/features/public-api/server/health-service";+import { __dangerouslySkipAuthz } from "@/src/features/public-api/server/enforceAuth";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/health/tools/index.ts b/web/src/features/mcp/server/health/tools/index.tsdeleted file mode 100644index 6782562bf0..0000000000--- a/web/src/features/mcp/server/health/tools/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./getHealth";diff --git a/web/src/features/mcp/server/llmConnections/tools/listLlmConnections.ts b/web/src/features/mcp/server/llmConnections/tools/listLlmConnections.tsindex 8f066e47f1..01f9a4666a 100644--- a/web/src/features/mcp/server/llmConnections/tools/listLlmConnections.ts+++ b/web/src/features/mcp/server/llmConnections/tools/listLlmConnections.ts@@ -1,8 +1,8 @@import { z } from "zod";import { LLMApiKeySchema, LLMConnectionConfigSchema } from "@langfuse/shared";-import { LlmConnectionService } from "@/src/features/llm-api-key/server";-import { BedrockAuthMethodSchema } from "@/src/features/llm-api-key";+import { LlmConnectionService } from "@/src/features/llm-api-key/server/llmConnectionService";+import { BedrockAuthMethodSchema } from "@/src/features/llm-api-key/types";import { defineTool } from "@/src/features/mcp/core/define-tool";import { runMcpTool } from "@/src/features/mcp/core/run-mcp-tool";diff --git a/web/src/features/mcp/server/mcpServer.ts b/web/src/features/mcp/server/mcpServer.tsindex b8ed04972c..0e5b51931d 100644--- a/web/src/features/mcp/server/mcpServer.ts+++ b/web/src/features/mcp/server/mcpServer.ts@@ -19,8 +19,8 @@ import {McpError,ErrorCode,} from "@modelcontextprotocol/sdk/types.js";-import { isProductFeedbackAvailable } from "@/src/features/feedback/server";-import { shadowAuthorize } from "@/src/features/public-api/server";+import { isProductFeedbackAvailable } from "@/src/features/feedback/server/FeedbackService";+import { shadowAuthorize } from "@/src/features/public-api/server/shadowAuth";import { formatErrorForUser } from "../core/error-formatting";import type { ServerContext } from "../types";import type { ToolDefinition } from "../core/define-tool";diff --git a/web/src/features/mcp/server/media/tools/getMedia.ts b/web/src/features/mcp/server/media/tools/getMedia.tsindex ffa3c52478..4bb53a470e 100644--- a/web/src/features/mcp/server/media/tools/getMedia.ts+++ b/web/src/features/mcp/server/media/tools/getMedia.ts@@ -1,4 +1,5 @@-import { getMedia, GetMediaQuerySchema } from "@/src/features/media/server";+import { getMedia } from "@/src/features/media/server/mediaService";+import { GetMediaQuerySchema } from "@/src/features/media/validation";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/metrics/tools/getMetricsSchema.ts b/web/src/features/mcp/server/metrics/tools/getMetricsSchema.tsindex c0d6dfbfa2..ce220b9028 100644--- a/web/src/features/mcp/server/metrics/tools/getMetricsSchema.ts+++ b/web/src/features/mcp/server/metrics/tools/getMetricsSchema.ts@@ -4,7 +4,7 @@ import {viewDeclarations,} from "@langfuse/shared/query";import { filterOperators } from "@langfuse/shared";-import { publicGranularities } from "@/src/features/public-api/server";+import { publicGranularities } from "@/src/features/public-api/types/metrics";import { z } from "zod";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/metrics/tools/queryMetrics.ts b/web/src/features/mcp/server/metrics/tools/queryMetrics.tsindex d61fc3eb86..9e57ff10b4 100644--- a/web/src/features/mcp/server/metrics/tools/queryMetrics.ts+++ b/web/src/features/mcp/server/metrics/tools/queryMetrics.ts@@ -10,12 +10,12 @@ import {import {MetricsQueryObjectV2,publicGranularities,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/metrics";import { defineTool } from "../../../core/define-tool";import { McpAdvancedFilterBaseSchema } from "../../../core/filter-schema";import { runMcpTool } from "../../../core/run-mcp-tool";import { MCP_CLICKHOUSE_SETTINGS } from "../../../core/clickhouse-settings";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";import { z } from "zod";const DEFAULT_ROW_LIMIT = 100;diff --git a/web/src/features/mcp/server/models/tools/createModel.ts b/web/src/features/mcp/server/models/tools/createModel.tsindex 5e289d6783..6492e1642c 100644--- a/web/src/features/mcp/server/models/tools/createModel.ts+++ b/web/src/features/mcp/server/models/tools/createModel.ts@@ -1,8 +1,8 @@import {PostModelsV1Body,PostModelsV1Response,-} from "@/src/features/public-api/server";-import { createModelForApi } from "@/src/features/models/server";+} from "@/src/features/public-api/types/models";+import { createModelForApi } from "@/src/features/models/server/publicApiModelService";import { defineTool } from "../../../core/define-tool";import { buildModelUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/models/tools/deleteModel.ts b/web/src/features/mcp/server/models/tools/deleteModel.tsindex 04ae56bc90..541dfe5cdc 100644--- a/web/src/features/mcp/server/models/tools/deleteModel.ts+++ b/web/src/features/mcp/server/models/tools/deleteModel.ts@@ -1,8 +1,8 @@import {DeleteModelV1Query,DeleteModelV1Response,-} from "@/src/features/public-api/server";-import { deleteModelForApi } from "@/src/features/models/server";+} from "@/src/features/public-api/types/models";+import { deleteModelForApi } from "@/src/features/models/server/publicApiModelService";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/models/tools/getModel.ts b/web/src/features/mcp/server/models/tools/getModel.tsindex 13aab9f61b..0e3c6e52c5 100644--- a/web/src/features/mcp/server/models/tools/getModel.ts+++ b/web/src/features/mcp/server/models/tools/getModel.ts@@ -1,8 +1,8 @@import {GetModelV1Query,GetModelV1Response,-} from "@/src/features/public-api/server";-import { getModelForApi } from "@/src/features/models/server";+} from "@/src/features/public-api/types/models";+import { getModelForApi } from "@/src/features/models/server/publicApiModelService";import { defineTool } from "../../../core/define-tool";import { buildModelUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/models/tools/index.ts b/web/src/features/mcp/server/models/tools/index.tsdeleted file mode 100644index 185aea8d6e..0000000000--- a/web/src/features/mcp/server/models/tools/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export * from "./createModel";-export * from "./deleteModel";-export * from "./getModel";-export * from "./listModels";diff --git a/web/src/features/mcp/server/models/tools/listModels.ts b/web/src/features/mcp/server/models/tools/listModels.tsindex 5276ae2fa3..197141d28e 100644--- a/web/src/features/mcp/server/models/tools/listModels.ts+++ b/web/src/features/mcp/server/models/tools/listModels.ts@@ -1,8 +1,8 @@import {GetModelsV1Query,GetModelsV1Response,-} from "@/src/features/public-api/server";-import { listModelsForApi } from "@/src/features/models/server";+} from "@/src/features/public-api/types/models";+import { listModelsForApi } from "@/src/features/models/server/publicApiModelService";import { defineTool } from "../../../core/define-tool";import { buildModelUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/observations/tools/getObservation.ts b/web/src/features/mcp/server/observations/tools/getObservation.tsindex 5b3fdf503c..53befec0df 100644--- a/web/src/features/mcp/server/observations/tools/getObservation.ts+++ b/web/src/features/mcp/server/observations/tools/getObservation.ts@@ -7,7 +7,7 @@ import {import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";import { MCP_CLICKHOUSE_SETTINGS } from "../../../core/clickhouse-settings";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";import {ExpandMetadataKeysSchema,getMetadataExpansionForProjection,diff --git a/web/src/features/mcp/server/observations/tools/getObservationFilterSchema.ts b/web/src/features/mcp/server/observations/tools/getObservationFilterSchema.tsindex 0179506b60..fd4ab02bb1 100644--- a/web/src/features/mcp/server/observations/tools/getObservationFilterSchema.ts+++ b/web/src/features/mcp/server/observations/tools/getObservationFilterSchema.ts@@ -6,7 +6,7 @@ import {OBSERVATION_MCP_ALLOWED_EVENTS_TABLE_FILTER_COLUMNS,} from "@langfuse/shared";import { defineTool } from "../../../core/define-tool";-import { observationEventsFilterConfig } from "@/src/features/events/server";+import { observationEventsFilterConfig } from "@/src/features/events/config/filter-config";const EmptyInputSchema = z.object({});const OBSERVATION_MCP_FILTER_COLUMNS = eventsTableColsdiff --git a/web/src/features/mcp/server/observations/tools/getObservationFilterValues.ts b/web/src/features/mcp/server/observations/tools/getObservationFilterValues.tsindex b08b8e7803..ae56f10d03 100644--- a/web/src/features/mcp/server/observations/tools/getObservationFilterValues.ts+++ b/web/src/features/mcp/server/observations/tools/getObservationFilterValues.ts@@ -7,7 +7,7 @@ import { z } from "zod";import {getEventFilterNumericRange,getEventFilterValuePage,-} from "@/src/features/events/server";+} from "@/src/features/events/server/eventsService";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";import { MCP_CLICKHOUSE_SETTINGS } from "../../../core/clickhouse-settings";@@ -15,7 +15,7 @@ import {ObservationLimitSchema,type ObservationMcpFilterColumn,} from "../schema";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";import {buildStartTimeFilters,OptionalStartTimeRangeShape,diff --git a/web/src/features/mcp/server/observations/tools/listObservations.ts b/web/src/features/mcp/server/observations/tools/listObservations.tsindex 410c9bed59..fb3bc33e86 100644--- a/web/src/features/mcp/server/observations/tools/listObservations.ts+++ b/web/src/features/mcp/server/observations/tools/listObservations.ts@@ -13,11 +13,11 @@ import {EncodedObservationsCursorV2,EncodedObservationsCursorV2String,encodeCursor,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/observations";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";import { MCP_CLICKHOUSE_SETTINGS } from "../../../core/clickhouse-settings";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";import { RateLimitService } from "@/src/features/public-api/server/RateLimitService";import {ExpandMetadataKeysSchema,diff --git a/web/src/features/mcp/server/prompts/tools/createChatPrompt.ts b/web/src/features/mcp/server/prompts/tools/createChatPrompt.tsindex 44ebba4811..0ae214c58c 100644--- a/web/src/features/mcp/server/prompts/tools/createChatPrompt.ts+++ b/web/src/features/mcp/server/prompts/tools/createChatPrompt.ts@@ -13,7 +13,7 @@ import {COMMIT_MESSAGE_MAX_LENGTH,PROMPT_NAME_MAX_LENGTH,} from "@langfuse/shared";-import { createPromptForApi } from "@/src/features/prompts/server";+import { createPromptForApi } from "@/src/features/prompts/server/prompt-api-service";import {buildPromptUrl,PromptChatMessageSchema,diff --git a/web/src/features/mcp/server/prompts/tools/createTextPrompt.ts b/web/src/features/mcp/server/prompts/tools/createTextPrompt.tsindex 84f1adb2a0..f09c9d1dfb 100644--- a/web/src/features/mcp/server/prompts/tools/createTextPrompt.ts+++ b/web/src/features/mcp/server/prompts/tools/createTextPrompt.ts@@ -13,7 +13,7 @@ import {COMMIT_MESSAGE_MAX_LENGTH,PROMPT_NAME_MAX_LENGTH,} from "@langfuse/shared";-import { createPromptForApi } from "@/src/features/prompts/server";+import { createPromptForApi } from "@/src/features/prompts/server/prompt-api-service";import { buildPromptUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";import { ParamCreatePromptLabels } from "../validation";diff --git a/web/src/features/mcp/server/prompts/tools/listPrompts.ts b/web/src/features/mcp/server/prompts/tools/listPrompts.tsindex f03aad0dfb..0d4345740c 100644--- a/web/src/features/mcp/server/prompts/tools/listPrompts.ts+++ b/web/src/features/mcp/server/prompts/tools/listPrompts.ts@@ -14,7 +14,7 @@ import {ParamPromptTag,} from "../validation";import { ParamLimit, ParamPage } from "../../../core/validation";-import { listPromptsForApi } from "@/src/features/prompts/server";+import { listPromptsForApi } from "@/src/features/prompts/server/prompt-api-service";import { buildPromptUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";import { paginationMeta } from "../../publicApi";diff --git a/web/src/features/mcp/server/prompts/tools/promptReadToolFactory.ts b/web/src/features/mcp/server/prompts/tools/promptReadToolFactory.tsindex 7fe41b5b18..8d4cf8de5b 100644--- a/web/src/features/mcp/server/prompts/tools/promptReadToolFactory.ts+++ b/web/src/features/mcp/server/prompts/tools/promptReadToolFactory.ts@@ -1,7 +1,7 @@import { z } from "zod";import { LATEST_PROMPT_LABEL, type Prompt } from "@langfuse/shared";-import { getPromptForApi } from "@/src/features/prompts/server";+import { getPromptForApi } from "@/src/features/prompts/server/prompt-api-service";import { defineTool } from "../../../core/define-tool";import { buildPromptUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/prompts/tools/updatePromptLabels.ts b/web/src/features/mcp/server/prompts/tools/updatePromptLabels.tsindex 83030d197e..a0739b282a 100644--- a/web/src/features/mcp/server/prompts/tools/updatePromptLabels.ts+++ b/web/src/features/mcp/server/prompts/tools/updatePromptLabels.ts@@ -9,7 +9,7 @@import { z } from "zod";import { defineTool } from "../../../core/define-tool";import { ParamPromptName, ParamNewLabels } from "../validation";-import { updatePromptLabelsForApi } from "@/src/features/prompts/server";+import { updatePromptLabelsForApi } from "@/src/features/prompts/server/prompt-api-service";import { buildPromptUrl } from "@langfuse/shared/src/server";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/publicApi.ts b/web/src/features/mcp/server/publicApi.tsindex ba540cbf28..7dd5a81fc0 100644--- a/web/src/features/mcp/server/publicApi.ts+++ b/web/src/features/mcp/server/publicApi.ts@@ -1,6 +1,6 @@import { CloudConfigSchema, type Plan } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import type { ServerContext } from "../types";export type McpPublicApiAuth = {diff --git a/web/src/features/mcp/server/scores/tools/createScore.ts b/web/src/features/mcp/server/scores/tools/createScore.tsindex d1f30c5529..8aeef80621 100644--- a/web/src/features/mcp/server/scores/tools/createScore.ts+++ b/web/src/features/mcp/server/scores/tools/createScore.ts@@ -6,7 +6,7 @@ import {PostScoresResponseV1,UnauthorizedError,} from "@langfuse/shared";-import { ScoresApiService } from "@/src/features/public-api/server";+import { ScoresApiService } from "@/src/features/public-api/server/scores-api-service";import {createUnknownSdkIngestionAttribution,buildScoreTargetUrl,diff --git a/web/src/features/mcp/server/scores/tools/createScoreConfig.ts b/web/src/features/mcp/server/scores/tools/createScoreConfig.tsindex 9fa9d200e9..6f27438f7e 100644--- a/web/src/features/mcp/server/scores/tools/createScoreConfig.ts+++ b/web/src/features/mcp/server/scores/tools/createScoreConfig.ts@@ -1,9 +1,7 @@import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";-import {- createScoreConfig,- PostScoreConfigBody,-} from "@/src/features/public-api/server";+import { createScoreConfig } from "@/src/features/public-api/server/score-configs-api-service";+import { PostScoreConfigBody } from "@/src/features/public-api/types/score-configs";import { z } from "zod";import {McpScoreConfigCategoricalCategoriesSchema,diff --git a/web/src/features/mcp/server/scores/tools/deleteScoreConfig.ts b/web/src/features/mcp/server/scores/tools/deleteScoreConfig.tsindex c995e371e7..e859ed1236 100644--- a/web/src/features/mcp/server/scores/tools/deleteScoreConfig.ts+++ b/web/src/features/mcp/server/scores/tools/deleteScoreConfig.ts@@ -1,9 +1,7 @@import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";-import {- updateScoreConfig,- PutScoreConfigQuery,-} from "@/src/features/public-api/server";+import { updateScoreConfig } from "@/src/features/public-api/server/score-configs-api-service";+import { PutScoreConfigQuery } from "@/src/features/public-api/types/score-configs";export const [deleteScoreConfigTool, handleDeleteScoreConfig] = defineTool({name: "deleteScoreConfig",diff --git a/web/src/features/mcp/server/scores/tools/getScore.ts b/web/src/features/mcp/server/scores/tools/getScore.tsindex e8a01dec04..e2c84902b3 100644--- a/web/src/features/mcp/server/scores/tools/getScore.ts+++ b/web/src/features/mcp/server/scores/tools/getScore.ts@@ -3,8 +3,10 @@ import { z } from "zod";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";import { MCP_CLICKHOUSE_SETTINGS } from "../../../core/clickhouse-settings";-import { listScoresV3ForPublicApi } from "@/src/features/public-api/server";-import { buildScoreSubjectUrl } from "@langfuse/shared/src/server";+import {+ listScoresV3ForPublicApi,+ buildScoreSubjectUrl,+} from "@langfuse/shared/src/server";const GetScoreInputSchema = z.object({ scoreId: z.string() }).strict();diff --git a/web/src/features/mcp/server/scores/tools/getScoreConfig.ts b/web/src/features/mcp/server/scores/tools/getScoreConfig.tsindex 86bfe29f49..6572302def 100644--- a/web/src/features/mcp/server/scores/tools/getScoreConfig.ts+++ b/web/src/features/mcp/server/scores/tools/getScoreConfig.ts@@ -1,9 +1,7 @@import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";-import {- getScoreConfig,- GetScoreConfigQuery,-} from "@/src/features/public-api/server";+import { getScoreConfig } from "@/src/features/public-api/server/score-configs-api-service";+import { GetScoreConfigQuery } from "@/src/features/public-api/types/score-configs";export const [getScoreConfigTool, handleGetScoreConfig] = defineTool({name: "getScoreConfig",diff --git a/web/src/features/mcp/server/scores/tools/listScoreConfigs.ts b/web/src/features/mcp/server/scores/tools/listScoreConfigs.tsindex 32695506bf..768c97c74f 100644--- a/web/src/features/mcp/server/scores/tools/listScoreConfigs.ts+++ b/web/src/features/mcp/server/scores/tools/listScoreConfigs.ts@@ -1,9 +1,7 @@import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";-import {- listScoreConfigs,- GetScoreConfigsQuery,-} from "@/src/features/public-api/server";+import { listScoreConfigs } from "@/src/features/public-api/server/score-configs-api-service";+import { GetScoreConfigsQuery } from "@/src/features/public-api/types/score-configs";export const [listScoreConfigsTool, handleListScoreConfigs] = defineTool({name: "listScoreConfigs",diff --git a/web/src/features/mcp/server/scores/tools/listScores.ts b/web/src/features/mcp/server/scores/tools/listScores.tsindex 59833c4524..ecda439fc7 100644--- a/web/src/features/mcp/server/scores/tools/listScores.ts+++ b/web/src/features/mcp/server/scores/tools/listScores.ts@@ -9,12 +9,12 @@ import { z } from "zod";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";import { MCP_CLICKHOUSE_SETTINGS } from "../../../core/clickhouse-settings";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";import {listScoresV3ForPublicApi,EncodedScoresCursorV3,-} from "@/src/features/public-api/server";-import { buildScoreSubjectUrl } from "@langfuse/shared/src/server";+ buildScoreSubjectUrl,+} from "@langfuse/shared/src/server";const ListScoresBaseSchema = z.object({diff --git a/web/src/features/mcp/server/scores/tools/updateScoreConfig.ts b/web/src/features/mcp/server/scores/tools/updateScoreConfig.tsindex ff274e5700..ce0bf4ea5f 100644--- a/web/src/features/mcp/server/scores/tools/updateScoreConfig.ts+++ b/web/src/features/mcp/server/scores/tools/updateScoreConfig.ts@@ -1,9 +1,7 @@import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";-import {- updateScoreConfig,- PutScoreConfigBodyWithoutArchived,-} from "@/src/features/public-api/server";+import { updateScoreConfig } from "@/src/features/public-api/server/score-configs-api-service";+import { PutScoreConfigBodyWithoutArchived } from "@/src/features/public-api/types/score-configs";import { z } from "zod";import {McpScoreConfigCategoricalCategoriesSchema,diff --git a/web/src/features/mcp/server/skills/tools/createSkillVersion.ts b/web/src/features/mcp/server/skills/tools/createSkillVersion.tsindex 2a27fdaa5a..8c599cebf7 100644--- a/web/src/features/mcp/server/skills/tools/createSkillVersion.ts+++ b/web/src/features/mcp/server/skills/tools/createSkillVersion.ts@@ -7,7 +7,7 @@ import {SkillVersionFileInputSchema,} from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/skills/tools/getSkill.ts b/web/src/features/mcp/server/skills/tools/getSkill.tsindex 08e8724564..3f51a3a105 100644--- a/web/src/features/mcp/server/skills/tools/getSkill.ts+++ b/web/src/features/mcp/server/skills/tools/getSkill.ts@@ -1,7 +1,7 @@import { z } from "zod";import { SkillNameSchema, SkillSelectorSchema } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/skills/tools/listSkills.ts b/web/src/features/mcp/server/skills/tools/listSkills.tsindex eb8be5e94c..c8d54dae90 100644--- a/web/src/features/mcp/server/skills/tools/listSkills.ts+++ b/web/src/features/mcp/server/skills/tools/listSkills.ts@@ -1,6 +1,6 @@import { ListSkillsQuerySchema } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/skills/tools/loadSkill.ts b/web/src/features/mcp/server/skills/tools/loadSkill.tsindex fb632771c9..a4b4a52c95 100644--- a/web/src/features/mcp/server/skills/tools/loadSkill.ts+++ b/web/src/features/mcp/server/skills/tools/loadSkill.ts@@ -1,7 +1,7 @@import { z } from "zod";import { SkillNameSchema, SkillSelectorSchema } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/skills/tools/loadSkillResource.ts b/web/src/features/mcp/server/skills/tools/loadSkillResource.tsindex c30691f071..549758fdfb 100644--- a/web/src/features/mcp/server/skills/tools/loadSkillResource.ts+++ b/web/src/features/mcp/server/skills/tools/loadSkillResource.ts@@ -5,7 +5,7 @@ import {SkillSelectorSchema,} from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/skills/tools/updateSkillLabels.ts b/web/src/features/mcp/server/skills/tools/updateSkillLabels.tsindex 7f8239fc61..4c062cf04a 100644--- a/web/src/features/mcp/server/skills/tools/updateSkillLabels.ts+++ b/web/src/features/mcp/server/skills/tools/updateSkillLabels.ts@@ -1,7 +1,7 @@import { z } from "zod";import { SkillNameSchema, UpdateSkillLabelsBodySchema } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/skills/tools/updateSkillTags.ts b/web/src/features/mcp/server/skills/tools/updateSkillTags.tsindex a82008780a..915def8310 100644--- a/web/src/features/mcp/server/skills/tools/updateSkillTags.ts+++ b/web/src/features/mcp/server/skills/tools/updateSkillTags.ts@@ -1,6 +1,6 @@import { SkillNameSchema, UpdateSkillTagsBodySchema } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";import { defineTool } from "../../../core/define-tool";import { runMcpTool } from "../../../core/run-mcp-tool";diff --git a/web/src/features/mcp/server/v4Migration/tools/getV4MigrationData.ts b/web/src/features/mcp/server/v4Migration/tools/getV4MigrationData.tsindex 99973c120f..9eae5201bf 100644--- a/web/src/features/mcp/server/v4Migration/tools/getV4MigrationData.ts+++ b/web/src/features/mcp/server/v4Migration/tools/getV4MigrationData.ts@@ -1,7 +1,7 @@import { prisma } from "@langfuse/shared/src/db";import { z } from "zod";-import { getProjectV4MigrationData } from "@/src/features/v4/server";+import { getProjectV4MigrationData } from "@/src/features/v4/server/v4TransitionService";import { defineTool } from "@/src/features/mcp/core/define-tool";import { runMcpTool } from "@/src/features/mcp/core/run-mcp-tool";diff --git a/web/src/features/media/index.ts b/web/src/features/media/index.tsdeleted file mode 100644index ab5d34d926..0000000000--- a/web/src/features/media/index.ts+++ /dev/null@@ -1,14 +0,0 @@-// The media feature's public client surface (RFC rule 8). Named-// re-exports only — the validation types other features already imported-// by file path.-//-// Schemas used by API routes stay on server/index.ts (rule 10).-// MediaEnabledFields stays a deep import. mediaService and-// datasetItemMediaReferences stay on the server door.-export {- MediaContentType,- type MediaReturnType,-} from "@/src/features/media/validation";-export { getSignedUrlState } from "@/src/features/media/fns/getSignedUrlState";-export { mediaUrlQueryOptions } from "@/src/features/media/constants/mediaUrlQueryOptions";-export { useMediaPeek } from "@/src/features/media/hooks/useMediaPeek";diff --git a/web/src/features/media/server/datasetItemMediaReferences.ts b/web/src/features/media/server/datasetItemMediaReferences.tsindex 1830352e11..334f99d9da 100644--- a/web/src/features/media/server/datasetItemMediaReferences.ts+++ b/web/src/features/media/server/datasetItemMediaReferences.ts@@ -1,6 +1,6 @@import { env } from "@/src/env.mjs";import { getMediaStorageServiceClient } from "@/src/features/media/server/getMediaStorageClient";-import { type APIDatasetItemMediaReference } from "@/src/features/public-api/server";+import type { APIDatasetItemMediaReference } from "@/src/features/public-api/types/datasets";import { logger } from "@langfuse/shared/src/server";import { prisma } from "@langfuse/shared/src/db";diff --git a/web/src/features/media/server/index.ts b/web/src/features/media/server/index.tsdeleted file mode 100644index 738907fa48..0000000000--- a/web/src/features/media/server/index.ts+++ /dev/null@@ -1,22 +0,0 @@-// The media feature's public server surface (RFC rules 8 and 10).-// mediaRouter stays a direct import from the tRPC root.-export {- createMediaUploadUrl,- getMedia,- updateMediaUploadStatus,-} from "@/src/features/media/server/mediaService";-export {- datasetItemMediaReferenceKey,- resolveDatasetItemMediaReferences,-} from "@/src/features/media/server/datasetItemMediaReferences";-export {- GetMediaQuerySchema,- GetMediaResponseSchema,- GetMediaUploadUrlQuerySchema,- GetMediaUploadUrlResponseSchema,- MediaContentType,- PatchMediaBodySchema,- type GetMediaResponse,- type GetMediaUploadUrlResponse,- type MediaReturnType,-} from "@/src/features/media/validation";diff --git a/web/src/features/metrics/components/ConnectedMetricsFilterBuilder.tsx b/web/src/features/metrics/components/ConnectedMetricsFilterBuilder.tsxindex 589f871a88..2205fade0c 100644--- a/web/src/features/metrics/components/ConnectedMetricsFilterBuilder.tsx+++ b/web/src/features/metrics/components/ConnectedMetricsFilterBuilder.tsx@@ -3,7 +3,7 @@ import { type FilterState, type TimeFilter } from "@langfuse/shared";import { type views, type ViewVersion } from "@langfuse/shared/query";import { type z } from "zod";import { api } from "@/src/utils/api";-import { useMetadataValueOptions } from "@/src/features/events";+import { useMetadataValueOptions } from "@/src/features/events/hooks/useMetadataValueOptions";import {getMetricsColumnsWithCustomSelect,getMetricsFilterColumns,diff --git a/web/src/features/metrics/components/MetricsFilterBuilder.tsx b/web/src/features/metrics/components/MetricsFilterBuilder.tsxindex dfa4726504..5fb502ae14 100644--- a/web/src/features/metrics/components/MetricsFilterBuilder.tsx+++ b/web/src/features/metrics/components/MetricsFilterBuilder.tsx@@ -17,12 +17,10 @@ import {displayNameForFilterColumn,mapViewFilterToUiTableFilter,partitionWidgetUiTableFiltersToView,-} from "@/src/features/dashboard";-import {- InlineFilterBuilder,- normalizeSingleValueOptions,- sortOptionValues,-} from "@/src/features/filters";+} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";+import { InlineFilterBuilder } from "@/src/features/filters/components/filter-builder";+import { normalizeSingleValueOptions } from "@/src/features/filters/lib/filter-transform";+import { sortOptionValues } from "@/src/features/filters/lib/option-sort";import { type GetMetricsFilterColumnsParams } from "@/src/features/metrics/metricsFilterColumns";const observationLevelOptions = ObservationLevelDomain.options.map((value) => ({diff --git a/web/src/features/metrics/index.ts b/web/src/features/metrics/index.tsdeleted file mode 100644index 0bff6a82be..0000000000--- a/web/src/features/metrics/index.ts+++ /dev/null@@ -1 +0,0 @@-export { ConnectedMetricsFilterBuilder } from "@/src/features/metrics/components/ConnectedMetricsFilterBuilder";diff --git a/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx b/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsxindex 2eccad8067..0da1974ae4 100644--- a/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx+++ b/web/src/features/mixpanel-integration/MixpanelIntegrationPage.tsx@@ -21,7 +21,7 @@ import {TooltipTrigger,TooltipContent,} from "@/src/components/ui/tooltip";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {mixpanelIntegrationFormSchema,MIXPANEL_REGIONS,@@ -41,10 +41,10 @@ import {getExportSourceFieldState,getExportSourceUnavailableMessage,isExportSourceSelectable,- IntegrationSettingsSkeleton,-} from "@/src/features/analytics-integrations";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useQueryProject } from "@/src/features/projects";+} from "@/src/features/analytics-integrations/exportSource";+import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations/components/IntegrationSettingsSkeleton";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useQueryProject } from "@/src/features/projects/hooks";import { useMixpanelIntegration } from "@/src/features/mixpanel-integration/useMixpanelIntegration";import { api } from "@/src/utils/api";import { type RouterOutput } from "@/src/utils/types";diff --git a/web/src/features/mixpanel-integration/mixpanel-integration-router.ts b/web/src/features/mixpanel-integration/mixpanel-integration-router.tsindex 3ef1b5fb38..f1dc887c07 100644--- a/web/src/features/mixpanel-integration/mixpanel-integration-router.ts+++ b/web/src/features/mixpanel-integration/mixpanel-integration-router.ts@@ -1,13 +1,13 @@import { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {assertPersistedExportSourceAllowed,resolveExportSource,- isPrismaRecordNotFoundError,- getDisplayCredential,-} from "@/src/features/analytics-integrations/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+} from "@/src/features/analytics-integrations/server/exportSource";+import { isPrismaRecordNotFoundError } from "@langfuse/shared/src/server";+import { getDisplayCredential } from "@/src/features/analytics-integrations/server/displayCredential";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/mixpanel-integration/useMixpanelIntegration.ts b/web/src/features/mixpanel-integration/useMixpanelIntegration.tsindex c758cf875d..b6f10be80d 100644--- a/web/src/features/mixpanel-integration/useMixpanelIntegration.ts+++ b/web/src/features/mixpanel-integration/useMixpanelIntegration.ts@@ -1,5 +1,5 @@import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";// An unconfigured integration reads as inactive on the integration page; thediff --git a/web/src/features/models/ModelDefinitionsTable/ConnectedModelDefinitionsTable.tsx b/web/src/features/models/ModelDefinitionsTable/ConnectedModelDefinitionsTable.tsxindex fae05af104..32add7a0d8 100644--- a/web/src/features/models/ModelDefinitionsTable/ConnectedModelDefinitionsTable.tsx+++ b/web/src/features/models/ModelDefinitionsTable/ConnectedModelDefinitionsTable.tsx@@ -15,8 +15,8 @@ import {import { TestModelMatchDialogContent } from "@/src/features/models/components/test-match/TestModelMatchDialogContent";import { usePriceUnitMultiplier } from "@/src/features/models/hooks/usePriceUnitMultiplier";import { type GetModelResult } from "@/src/features/models/validation";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { usePaginationState } from "@/src/hooks/usePaginationState";import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";import {diff --git a/web/src/features/models/ModelDetailPage.tsx b/web/src/features/models/ModelDetailPage.tsxindex 6cb8803900..41bd06d157 100644--- a/web/src/features/models/ModelDetailPage.tsx+++ b/web/src/features/models/ModelDetailPage.tsx@@ -1,6 +1,6 @@import { useRouter } from "next/router";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {Card,CardContent,@@ -19,7 +19,7 @@ import Decimal from "decimal.js";import { PriceUnitSelector } from "@/src/features/models/components/PriceUnitSelector";import { useMemo, useState } from "react";import { usePriceUnitMultiplier } from "@/src/features/models/hooks/usePriceUnitMultiplier";-import { ObservationsTable as Generations } from "@/src/features/tracing-tables";+import { default as Generations } from "@/src/features/tracing-tables/observations/ObservationsTable";import Page from "@/src/components/layouts/Page";import { SquareArrowOutUpRight, Info as InfoIcon } from "@langfuse/icons";import {@@ -30,7 +30,7 @@ import {SelectValue,} from "@/src/components/ui/select";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";const resolvePricingTier = <T extends { id: string }>(tiers: T[],diff --git a/web/src/features/models/components/CloneModelButton.tsx b/web/src/features/models/components/CloneModelButton.tsxindex bce5fa5751..68f78abd5a 100644--- a/web/src/features/models/components/CloneModelButton.tsx+++ b/web/src/features/models/components/CloneModelButton.tsx@@ -1,5 +1,5 @@import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { UpsertModelFormDialogController } from "@/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController";import { type GetModelResult } from "@/src/features/models/validation";diff --git a/web/src/features/models/components/DeleteModelButton.tsx b/web/src/features/models/components/DeleteModelButton.tsxindex 5d9c8fc810..27be8cfc28 100644--- a/web/src/features/models/components/DeleteModelButton.tsx+++ b/web/src/features/models/components/DeleteModelButton.tsx@@ -1,9 +1,9 @@/* eslint-disable @repo/no-abstracted-overlay-trigger */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Button } from "@/src/components/ui/button";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { type GetModelResult } from "@/src/features/models/validation";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";import { useState } from "react";diff --git a/web/src/features/models/components/EditModelButton.tsx b/web/src/features/models/components/EditModelButton.tsxindex 9f9af0424f..982c2a468e 100644--- a/web/src/features/models/components/EditModelButton.tsx+++ b/web/src/features/models/components/EditModelButton.tsx@@ -1,5 +1,5 @@import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { UpsertModelFormDialogController } from "@/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController";import { type GetModelResult } from "@/src/features/models/validation";diff --git a/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.clienttest.tsx b/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.clienttest.tsxindex bbd2a49a65..ff89830a76 100644--- a/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.clienttest.tsx+++ b/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.clienttest.tsx@@ -43,7 +43,7 @@ vi.mock("@/src/features/notifications/showSuccessToast", () => ({showSuccessToast: vi.fn(),}));-vi.mock("@/src/components/editor", () => ({+vi.mock("@/src/components/editor/CodeMirrorEditor", () => ({CodeMirrorEditor: () => null,}));diff --git a/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.tsx b/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.tsxindex d6f5899997..5a2ea2a367 100644--- a/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.tsx+++ b/web/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController.tsx@@ -6,7 +6,7 @@ import Link from "next/link";import { useImperativeHandle, useRef, useState, type Ref } from "react";import { useForm } from "react-hook-form";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { Button } from "@/src/components/ui/button";import {@@ -42,12 +42,12 @@ import {FormUpsertModelSchema,type GetModelResult,} from "@/src/features/models/validation";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { zodResolver } from "@hookform/resolvers/zod";import { useRouter } from "next/router";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { PricingSection } from "@/src/features/models/components/PricingSection/PricingSection";type DialogChild = (control: { openDialog: () => void }) => React.ReactNode;diff --git a/web/src/features/models/index.ts b/web/src/features/models/index.tsdeleted file mode 100644index b5870aeb94..0000000000--- a/web/src/features/models/index.ts+++ /dev/null@@ -1,5 +0,0 @@-// The models feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export { ModelsSettings } from "@/src/features/models/components/ModelsSettings";-export { ProvidedModelNameCell } from "@/src/features/models/components/ProvidedModelNameCell";-export { UpsertModelFormDialogController } from "@/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController";diff --git a/web/src/features/models/server/index.ts b/web/src/features/models/server/index.tsdeleted file mode 100644index 6b3d8bf33f..0000000000--- a/web/src/features/models/server/index.ts+++ /dev/null@@ -1,9 +0,0 @@-// The models feature's server surface (RFC rule 9, amended): the-// public-API model service MCP tools already imported by file path.-export {- createModelForApi,- deleteModelForApi,- getModelForApi,- listModelsForApi,- upsertModelForApi,-} from "@/src/features/models/server/publicApiModelService";diff --git a/web/src/features/models/server/publicApiModelService.ts b/web/src/features/models/server/publicApiModelService.tsindex 56e52b2ffc..5145dc32e8 100644--- a/web/src/features/models/server/publicApiModelService.ts+++ b/web/src/features/models/server/publicApiModelService.ts@@ -1,4 +1,4 @@-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { isValidPostgresRegex } from "@/src/features/models/server/isValidPostgresRegex";import {type DeleteModelV1Query,@@ -6,7 +6,8 @@ import {type GetModelsV1Query,type PostModelsV1Body,prismaToApiModelDefinition,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/models";+import { InvalidRequestError, LangfuseNotFoundError } from "@langfuse/shared";import { Prisma, prisma } from "@langfuse/shared/src/db";import { clearModelCacheForProject } from "@langfuse/shared/src/server";diff --git a/web/src/features/monitors/automations/ConnectedNewMonitorAutomationDialog.clienttest.tsx b/web/src/features/monitors/automations/ConnectedNewMonitorAutomationDialog.clienttest.tsxindex 83c0516966..81db771303 100644--- a/web/src/features/monitors/automations/ConnectedNewMonitorAutomationDialog.clienttest.tsx+++ b/web/src/features/monitors/automations/ConnectedNewMonitorAutomationDialog.clienttest.tsx@@ -24,13 +24,19 @@ vi.mock("@/src/utils/api", () => ({},},}));-vi.mock("@/src/features/pagerduty", () => ({+vi.mock("@/src/features/pagerduty/hooks/usePagerDutyTestEvent", () => ({usePagerDutyTestEvent: () => ({}),}));-vi.mock("@/src/features/rbac", () => ({ useHasProjectAccess: () => true }));-vi.mock("@/src/features/slack", () => ({+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({+ useHasProjectAccess: () => true,+}));+vi.mock("@/src/features/slack/hooks/useChannelSelectorData", () => ({useChannelSelectorData: () => ({ canListChannels: true }),+}));+vi.mock("@/src/features/slack/hooks/useSlackConnect", () => ({useSlackConnect: () => ({ connect: vi.fn(), canConnect: true }),+}));+vi.mock("@/src/features/slack/hooks/useSlackTestMessage", () => ({useSlackTestMessage: () => ({ sendTestMessage: vi.fn() }),}));/** submitResult is what the dialog's onSubmit resolved to. */diff --git a/web/src/features/monitors/automations/ConnectedNewMonitorAutomationDialog.tsx b/web/src/features/monitors/automations/ConnectedNewMonitorAutomationDialog.tsxindex b7d4617cd2..438b66220b 100644--- a/web/src/features/monitors/automations/ConnectedNewMonitorAutomationDialog.tsx+++ b/web/src/features/monitors/automations/ConnectedNewMonitorAutomationDialog.tsx@@ -1,11 +1,9 @@import { type ActionTypes } from "@langfuse/shared";-import { usePagerDutyTestEvent } from "@/src/features/pagerduty";-import { useHasProjectAccess } from "@/src/features/rbac";-import {- useChannelSelectorData,- useSlackConnect,- useSlackTestMessage,-} from "@/src/features/slack";+import { usePagerDutyTestEvent } from "@/src/features/pagerduty/hooks/usePagerDutyTestEvent";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useChannelSelectorData } from "@/src/features/slack/hooks/useChannelSelectorData";+import { useSlackConnect } from "@/src/features/slack/hooks/useSlackConnect";+import { useSlackTestMessage } from "@/src/features/slack/hooks/useSlackTestMessage";import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";import { type SlackFieldsState } from "./components/SlackActionFields";import { buildCreateMonitorAutomationInput } from "./helpers/buildCreateMonitorAutomationInput";diff --git a/web/src/features/monitors/automations/NewMonitorAutomationDialogController.tsx b/web/src/features/monitors/automations/NewMonitorAutomationDialogController.tsxindex 315c10eb45..d2ac73c9fb 100644--- a/web/src/features/monitors/automations/NewMonitorAutomationDialogController.tsx+++ b/web/src/features/monitors/automations/NewMonitorAutomationDialogController.tsx@@ -2,7 +2,7 @@ import { type ReactNode } from "react";import { type ActionTypes } from "@langfuse/shared";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { WebhookSecretDialog } from "./components/WebhookSecretDialog";import {ConnectedNewMonitorAutomationDialog,diff --git a/web/src/features/monitors/automations/components/NewMonitorAutomationDialog.tsx b/web/src/features/monitors/automations/components/NewMonitorAutomationDialog.tsxindex 94ae632a3a..3cfe6b9f6c 100644--- a/web/src/features/monitors/automations/components/NewMonitorAutomationDialog.tsx+++ b/web/src/features/monitors/automations/components/NewMonitorAutomationDialog.tsx@@ -3,7 +3,7 @@ import { useForm, useWatch, type UseFormReturn } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { type ActionTypes } from "@langfuse/shared";-import { type PagerDutyTestEventState } from "@/src/features/pagerduty";+import { type PagerDutyTestEventState } from "@/src/features/pagerduty/hooks/usePagerDutyTestEvent";import { Dialog } from "@/src/components/design-system/Dialog/Dialog";import { Form } from "@/src/components/design-system/Form/Form";import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";diff --git a/web/src/features/monitors/automations/components/PagerDutyActionFields.tsx b/web/src/features/monitors/automations/components/PagerDutyActionFields.tsxindex 6cc940dd51..b0bc44e103 100644--- a/web/src/features/monitors/automations/components/PagerDutyActionFields.tsx+++ b/web/src/features/monitors/automations/components/PagerDutyActionFields.tsx@@ -1,10 +1,8 @@import { type UseFormReturn } from "react-hook-form";import { type PagerDutyRegion } from "@langfuse/shared/pagerduty";-import {- PagerDutyTestEventButtonsView,- type PagerDutyTestEventState,-} from "@/src/features/pagerduty";+import { PagerDutyTestEventButtonsView } from "@/src/features/pagerduty/components/PagerDutyTestEventButtonsView";+import { type PagerDutyTestEventState } from "@/src/features/pagerduty/hooks/usePagerDutyTestEvent";import { Form } from "@/src/components/design-system/Form/Form";import { type MonitorAutomationFormValues } from "../helpers/monitorAutomationFormSchema";diff --git a/web/src/features/monitors/automations/components/SlackActionFields.tsx b/web/src/features/monitors/automations/components/SlackActionFields.tsxindex ff817c7a08..cb90378c00 100644--- a/web/src/features/monitors/automations/components/SlackActionFields.tsx+++ b/web/src/features/monitors/automations/components/SlackActionFields.tsx@@ -7,9 +7,9 @@ import { Form } from "@/src/components/design-system/Form/Form";import {ChannelSelectorView,type ChannelSelectorViewProps,- type SlackChannel,- type SlackTestMessageResult,-} from "@/src/features/slack";+} from "@/src/features/slack/components/ChannelSelectorView/ChannelSelectorView";+import { type SlackTestMessageResult } from "@/src/features/slack/hooks/useSlackTestMessage";+import { type SlackChannel } from "@/src/features/slack/components/ChannelSelector";import { type MonitorAutomationFormValues } from "../helpers/monitorAutomationFormSchema";import { FieldGroup } from "./FieldGroup";diff --git a/web/src/features/monitors/components/MonitorAutomationsPanel.tsx b/web/src/features/monitors/components/MonitorAutomationsPanel.tsxindex 37fa122d69..814315d67e 100644--- a/web/src/features/monitors/components/MonitorAutomationsPanel.tsx+++ b/web/src/features/monitors/components/MonitorAutomationsPanel.tsx@@ -13,7 +13,7 @@ import { api } from "@/src/utils/api";import { Button } from "@/src/components/ui/button";import { Card, CardContent } from "@/src/components/ui/card";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";-import { actionTypeLabel } from "@/src/features/automations";+import { actionTypeLabel } from "@/src/features/automations/actionTypeLabels";import { NewMonitorAutomationDialogController } from "@/src/features/monitors/automations/NewMonitorAutomationDialogController";import { cn } from "@/src/utils/tailwind";import {diff --git a/web/src/features/monitors/components/MonitorChartPreview.tsx b/web/src/features/monitors/components/MonitorChartPreview.tsxindex 382896941a..a831508c43 100644--- a/web/src/features/monitors/components/MonitorChartPreview.tsx+++ b/web/src/features/monitors/components/MonitorChartPreview.tsx@@ -4,12 +4,10 @@ import { type z } from "zod";import { api } from "@/src/utils/api";import { Card, CardContent } from "@/src/components/ui/card";-import {- Chart,- ChartLoadingState,- type DataPoint,- getWidgetMetricPresentation,-} from "@/src/features/widgets";+import { Chart } from "@/src/features/widgets/chart-library/Chart";+import { ChartLoadingState } from "@/src/features/widgets/chart-library/ChartLoadingState";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";+import { getWidgetMetricPresentation } from "@/src/features/widgets/utils";import {type FilterState,type metricAggregations,diff --git a/web/src/features/monitors/components/MonitorForm.tsx b/web/src/features/monitors/components/MonitorForm.tsxindex f3b709668f..fb1d1f2eb4 100644--- a/web/src/features/monitors/components/MonitorForm.tsx+++ b/web/src/features/monitors/components/MonitorForm.tsx@@ -1,6 +1,7 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-use-before-define *//* eslint-disable @repo/no-style-props */-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import React, { useMemo, useRef } from "react";import * as AccordionPrimitive from "@radix-ui/react-accordion";import { useRouter } from "next/router";@@ -38,11 +39,11 @@ import {SelectTrigger,SelectValue,} from "@/src/components/ui/select";-import { useHasProjectAccess } from "@/src/features/rbac";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useProject } from "@/src/features/projects";-import { partitionWidgetUiTableFiltersToView } from "@/src/features/dashboard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useProject } from "@/src/features/projects/hooks";+import { partitionWidgetUiTableFiltersToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {resolveMonitorNameForSave,type MonitorNameResolution,@@ -68,7 +69,7 @@ import {} from "@langfuse/shared/monitors";import { viewDeclarations, type FilterState } from "@langfuse/shared";-import { TagManager } from "@/src/features/tag";+import { default as TagManager } from "@/src/features/tag/components/TagManager";import { MonitorChartPreview } from "./MonitorChartPreview";import { getMonitorFilterOptionsLookbackFrom } from "../helpers/monitorTimeRanges";import { MonitorAutomationsPanel } from "./MonitorAutomationsPanel";diff --git a/web/src/features/monitors/components/MonitorMetricDefinition.tsx b/web/src/features/monitors/components/MonitorMetricDefinition.tsxindex 168683e609..dab104b3a2 100644--- a/web/src/features/monitors/components/MonitorMetricDefinition.tsx+++ b/web/src/features/monitors/components/MonitorMetricDefinition.tsx@@ -11,11 +11,9 @@ import {} from "@/src/components/ui/form";import { Label } from "@/src/components/ui/label";import { SelectDropdown } from "@/src/components/design-system/SelectDropdown/SelectDropdown";-import {- CompactConnectorRow,- CompactPickerButton,-} from "@/src/features/filters";-import { ConnectedMetricsFilterBuilder } from "@/src/features/metrics";+import { CompactConnectorRow } from "@/src/features/filters/components/CompactConnectorRow";+import { CompactPickerButton } from "@/src/features/filters/components/CompactPickerButton";+import { ConnectedMetricsFilterBuilder } from "@/src/features/metrics/components/ConnectedMetricsFilterBuilder";import { viewDeclarations, type FilterState } from "@langfuse/shared";import {type CreateMonitor,diff --git a/web/src/features/monitors/components/MonitorPagePermissions.tsx b/web/src/features/monitors/components/MonitorPagePermissions.tsxindex 9a0e3b5c96..e0b4d9a3e9 100644--- a/web/src/features/monitors/components/MonitorPagePermissions.tsx+++ b/web/src/features/monitors/components/MonitorPagePermissions.tsx@@ -1,9 +1,9 @@import { type ReactNode } from "react";import { ErrorPage } from "@/src/components/error-page";-import { SupportOrUpgradePage } from "@/src/ee/features/billing";-import { useLangfuseV4WriteMode } from "@/src/features/organizations";-import { useHasProjectAccess } from "@/src/features/rbac";+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";+import { useLangfuseV4WriteMode } from "@/src/features/organizations/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";/** MonitorScope is the RBAC scope a monitor page can require for entry. */diff --git a/web/src/features/monitors/components/MonitorsOnboarding.tsx b/web/src/features/monitors/components/MonitorsOnboarding.tsxindex b5e2876793..b1f1fa0acd 100644--- a/web/src/features/monitors/components/MonitorsOnboarding.tsx+++ b/web/src/features/monitors/components/MonitorsOnboarding.tsx@@ -6,7 +6,7 @@ import { ActionButton } from "@/src/components/ActionButton";import { Button } from "@/src/components/ui/button";import { SplashScreen } from "@/src/components/ui/SplashScreen";import { NewMonitorAutomationDialogController } from "@/src/features/monitors/automations/NewMonitorAutomationDialogController";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { type ActionTypes } from "@langfuse/shared";/** OnboardingChannel describes one notification-channel CTA shown in step 1 of the splash. */diff --git a/web/src/features/monitors/components/MonitorsTable.clienttest.ts b/web/src/features/monitors/components/MonitorsTable.clienttest.tsindex 4a3fff2887..6e29a9cba9 100644--- a/web/src/features/monitors/components/MonitorsTable.clienttest.ts+++ b/web/src/features/monitors/components/MonitorsTable.clienttest.ts@@ -10,7 +10,7 @@ import {MonitorThresholdOperatorSchema,} from "@langfuse/shared/monitors";-import { getMonitorFilterConfig } from "@/src/features/filters";+import { getMonitorFilterConfig } from "@/src/features/filters/config/monitors-config";import { __test } from "./MonitorsTable";const { filterStateToListMonitorFilter, buildStatusToggleUpdate } = __test;diff --git a/web/src/features/monitors/components/MonitorsTable.tsx b/web/src/features/monitors/components/MonitorsTable.tsxindex 11dd978ba5..d97248fbe6 100644--- a/web/src/features/monitors/components/MonitorsTable.tsx+++ b/web/src/features/monitors/components/MonitorsTable.tsx@@ -24,14 +24,13 @@ import {DropdownMenuItem,DropdownMenuTrigger,} from "@/src/components/ui/dropdown-menu";-import {- getMonitorFilterConfig,- useSidebarFilterState,-} from "@/src/features/filters";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";-import { useOrderByState } from "@/src/features/orderBy";-import { useHasProjectAccess } from "@/src/features/rbac";-import { TagList } from "@/src/features/tag";+import { getMonitorFilterConfig } from "@/src/features/filters/config/monitors-config";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { default as TagList } from "@/src/features/tag/components/TagList";import { usePaginationState } from "@/src/hooks/usePaginationState";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { api, type RouterInputs, type RouterOutputs } from "@/src/utils/api";@@ -47,14 +46,13 @@ import {} from "@langfuse/shared/monitors";import { MonitorSeverityBadge } from "./MonitorSeverityBadge";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";-import { TableSearchBar, toObservedOptions } from "@/src/features/search-bar";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { monitorsFieldRegistry } from "@/src/features/monitors/constants/monitorsSearchRegistry";import { hasEmptyCheckboxSelection } from "@/src/features/filters/lib/sidebar-filter-actions";diff --git a/web/src/features/monitors/constants/monitorsSearchRegistry.clienttest.ts b/web/src/features/monitors/constants/monitorsSearchRegistry.clienttest.tsindex 644fed7d08..c72bc25024 100644--- a/web/src/features/monitors/constants/monitorsSearchRegistry.clienttest.ts+++ b/web/src/features/monitors/constants/monitorsSearchRegistry.clienttest.ts@@ -1,13 +1,11 @@import { describe, expect, it } from "vitest";-import { getMonitorFilterConfig } from "@/src/features/filters";+import { getMonitorFilterConfig } from "@/src/features/filters/config/monitors-config";import { monitorsFieldRegistry } from "./monitorsSearchRegistry";-import {- astToFilterState,- planCommit,- parse,- validateQuery,- createSearchBarStore,-} from "@/src/features/search-bar";+import { astToFilterState } from "@/src/features/search-bar/lib/adapter";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { parse } from "@/src/features/search-bar/lib/langQ";+import { validateQuery } from "@/src/features/search-bar/lib/validate";+import { createSearchBarStore } from "@/src/features/search-bar/store/searchBarStore";import { ListMonitorFilterSchema } from "@langfuse/shared/monitors";diff --git a/web/src/features/monitors/constants/monitorsSearchRegistry.ts b/web/src/features/monitors/constants/monitorsSearchRegistry.tsindex 786c9340e2..a6275d77fd 100644--- a/web/src/features/monitors/constants/monitorsSearchRegistry.ts+++ b/web/src/features/monitors/constants/monitorsSearchRegistry.ts@@ -1,6 +1,6 @@import { ListMonitorFilterSchema } from "@langfuse/shared/monitors";-import type { FilterConfig } from "@/src/features/filters";-import { fieldRegistryFromColumns } from "@/src/features/search-bar";+import type { FilterConfig } from "@/src/features/filters/lib/filter-config";+import { fieldRegistryFromColumns } from "@/src/features/search-bar/lib/fields";export function monitorsFieldRegistry(config: FilterConfig) {const facetColumns = new Set(config.facets.map((facet) => facet.column));diff --git a/web/src/features/monitors/index.ts b/web/src/features/monitors/index.tsdeleted file mode 100644index 9b22c7fc62..0000000000--- a/web/src/features/monitors/index.ts+++ /dev/null@@ -1 +0,0 @@-export { MonitorSeverityBadge } from "@/src/features/monitors/components/MonitorSeverityBadge";diff --git a/web/src/features/monitors/pages/EditMonitorPage.tsx b/web/src/features/monitors/pages/EditMonitorPage.tsxindex 963343dc64..6e972435ff 100644--- a/web/src/features/monitors/pages/EditMonitorPage.tsx+++ b/web/src/features/monitors/pages/EditMonitorPage.tsx@@ -8,8 +8,9 @@ import { DeleteMonitorButton } from "@/src/features/monitors/components/DeleteMoimport { MonitorForm } from "@/src/features/monitors/components/MonitorForm";import { MonitorPagePermissions } from "@/src/features/monitors/components/MonitorPagePermissions";import { invalidateMonitorQueriesAfterDelete } from "@/src/features/monitors/fns/invalidateMonitorQueriesAfterDelete";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api, type APIError } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { type Monitor } from "@langfuse/shared/monitors";diff --git a/web/src/features/monitors/pages/ListMonitorsPage.tsx b/web/src/features/monitors/pages/ListMonitorsPage.tsxindex 97fd068f4d..766d69c247 100644--- a/web/src/features/monitors/pages/ListMonitorsPage.tsx+++ b/web/src/features/monitors/pages/ListMonitorsPage.tsx@@ -5,13 +5,13 @@ import { ActionButton } from "@/src/components/ActionButton";import Page from "@/src/components/layouts/Page";import { DataTableControlsProvider } from "@/src/components/table/data-table-controls";import { FilterToggleButton } from "@/src/components/table/FilterToggleButton";-import { AutomationButton } from "@/src/features/automations";-import { useEntitlementLimit } from "@/src/features/entitlements";-import { monitorFilterConfig } from "@/src/features/filters";+import { AutomationButton } from "@/src/features/automations/components/AutomationButton";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";+import { monitorFilterConfig } from "@/src/features/filters/config/monitors-config";import { MonitorPagePermissions } from "@/src/features/monitors/components/MonitorPagePermissions";import { MonitorsOnboarding } from "@/src/features/monitors/components/MonitorsOnboarding";import { MonitorsTable } from "@/src/features/monitors/components/MonitorsTable";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { api } from "@/src/utils/api";diff --git a/web/src/features/monitors/server/index.ts b/web/src/features/monitors/server/index.tsdeleted file mode 100644index 6dee3a99a5..0000000000--- a/web/src/features/monitors/server/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { listLinkedEvaluatorAlerts } from "@/src/features/monitors/server/listLinkedEvaluatorAlerts";-export { suggestMonitorName } from "@/src/features/monitors/server/suggestMonitorName";diff --git a/web/src/features/monitors/server/suggestMonitorName.ts b/web/src/features/monitors/server/suggestMonitorName.tsindex 488e62a7c0..edc6fe6003 100644--- a/web/src/features/monitors/server/suggestMonitorName.ts+++ b/web/src/features/monitors/server/suggestMonitorName.ts@@ -7,7 +7,7 @@ import {logger,} from "@langfuse/shared/src/server";-import { resolveLangfuseAiFeatureAvailability } from "@/src/features/ai-features/server";+import { resolveLangfuseAiFeatureAvailability } from "@/src/features/ai-features/server/availability";/** Generates a concise monitor name when Langfuse AI features are available. */export async function suggestMonitorName({diff --git a/web/src/features/natural-language-filters/server/index.ts b/web/src/features/natural-language-filters/server/index.tsdeleted file mode 100644index 08f9d360e5..0000000000--- a/web/src/features/natural-language-filters/server/index.ts+++ /dev/null@@ -1 +0,0 @@-export { getLangfuseClient } from "@/src/features/natural-language-filters/server/utils";diff --git a/web/src/features/natural-language-filters/server/router.ts b/web/src/features/natural-language-filters/server/router.tsindex 24a65644b0..4a9568b195 100644--- a/web/src/features/natural-language-filters/server/router.ts+++ b/web/src/features/natural-language-filters/server/router.ts@@ -19,7 +19,7 @@ import {import { env } from "@/src/env.mjs";import { CreateNaturalLanguageFilterCompletion } from "./validation";import { parseFiltersFromCompletion, getLangfuseClient } from "./utils";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export const naturalLanguageFilterRouter = createTRPCRouter({createCompletion: protectedProjectProcedurediff --git a/web/src/features/navigate-detail-pages/DetailPageNav.tsx b/web/src/features/navigate-detail-pages/DetailPageNav.tsxindex 04a8c4ee24..85a7c3e28e 100644--- a/web/src/features/navigate-detail-pages/DetailPageNav.tsx+++ b/web/src/features/navigate-detail-pages/DetailPageNav.tsx@@ -6,8 +6,8 @@ import {type ListEntry,useDetailPageLists,} from "@/src/features/navigate-detail-pages/DetailPageListsProvider";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useReadPath } from "@/src/features/events";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { cn } from "@/src/utils/tailwind";import { ArrowDown, ArrowUp } from "@langfuse/icons";import { useRouter } from "next/router";diff --git a/web/src/features/navigate-detail-pages/index.ts b/web/src/features/navigate-detail-pages/index.tsdeleted file mode 100644index 22e4d383a0..0000000000--- a/web/src/features/navigate-detail-pages/index.ts+++ /dev/null@@ -1,13 +0,0 @@-// The navigate-detail-pages feature's public client surface (RFC rule 8).-// Named re-exports only — exactly what other features already imported.-export {- DetailPageListsProvider,- detailPageListKeys,- useDetailPageLists,- useFirstDetailPageListEntry,- type EventDetailPageListEntry,- type ListEntry,- type ObservationDetailPageListEntry,- type TraceDetailPageListEntry,-} from "@/src/features/navigate-detail-pages/DetailPageListsProvider";-export { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";diff --git a/web/src/features/navigation/index.ts b/web/src/features/navigation/index.tsdeleted file mode 100644index 90f55f1b14..0000000000--- a/web/src/features/navigation/index.ts+++ /dev/null@@ -1,40 +0,0 @@-// The navigation feature's public client surface (RFC rule 8). Named-// re-exports only — the tab helpers other features already imported by-// file path. Pages stay off this door.-export {- DASHBOARD_TABS,- getDashboardTabs,-} from "@/src/features/navigation/utils/dashboard-tabs";-export {- DATASET_ITEM_TABS,- getDatasetItemTabs,- type DatasetItemTab,-} from "@/src/features/navigation/utils/dataset-item-tabs";-export {- DATASET_RUN_COMPARE_TABS,- getDatasetRunCompareTabs,-} from "@/src/features/navigation/utils/dataset-run-compare-tabs";-export {- DATASET_TABS,- getDatasetTabs,-} from "@/src/features/navigation/utils/dataset-tabs";-export {- EVALS_TABS,- getEvalsTabs,-} from "@/src/features/navigation/utils/evals-tabs";-export {- EVALS_V2_TABS,- getEvalsV2Tabs,-} from "@/src/features/navigation/utils/evals-v2-tabs";-export {- PROMPT_TABS,- getPromptTabs,-} from "@/src/features/navigation/utils/prompt-tabs";-export {- SCORES_TABS,- getScoresTabs,-} from "@/src/features/navigation/utils/scores-tabs";-export {- TRACING_TABS,- getTracingTabs,-} from "@/src/features/navigation/utils/tracing-tabs";diff --git a/web/src/features/notifications/ErrorNotification.clienttest.tsx b/web/src/features/notifications/ErrorNotification.clienttest.tsxindex 075bacbc6e..aa27d68eac 100644--- a/web/src/features/notifications/ErrorNotification.clienttest.tsx+++ b/web/src/features/notifications/ErrorNotification.clienttest.tsx@@ -9,11 +9,11 @@ const mocks = vi.hoisted(() => ({setSupportDrawerOpen: vi.fn(),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => mocks.capture,}));-vi.mock("@/src/features/support-chat", () => ({+vi.mock("@/src/features/support-chat/SupportDrawerProvider", () => ({useSupportDrawer: () => ({ setOpen: mocks.setSupportDrawerOpen }),}));diff --git a/web/src/features/notifications/ErrorNotification.tsx b/web/src/features/notifications/ErrorNotification.tsxindex 4861fad05d..5d65f74af5 100644--- a/web/src/features/notifications/ErrorNotification.tsx+++ b/web/src/features/notifications/ErrorNotification.tsx@@ -4,8 +4,8 @@ import {type ToastErrorAnalytics,getToastErrorProperties,} from "@/src/features/notifications/toastAnalytics";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useSupportDrawer } from "@/src/features/support-chat";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";import { useV4MigrationPanel } from "@/src/features/v4-migration/V4MigrationPanelProvider";import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";import { AlertTriangle, Check, Copy, X } from "@langfuse/icons";diff --git a/web/src/features/notifications/SuccessNotification.clienttest.tsx b/web/src/features/notifications/SuccessNotification.clienttest.tsxindex f653aa24b3..311c65649c 100644--- a/web/src/features/notifications/SuccessNotification.clienttest.tsx+++ b/web/src/features/notifications/SuccessNotification.clienttest.tsx@@ -6,7 +6,7 @@ const mocks = vi.hoisted(() => ({capture: vi.fn(),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => mocks.capture,}));diff --git a/web/src/features/notifications/SuccessNotification.tsx b/web/src/features/notifications/SuccessNotification.tsxindex 6084e6903c..ae8f39a2d7 100644--- a/web/src/features/notifications/SuccessNotification.tsx+++ b/web/src/features/notifications/SuccessNotification.tsx@@ -1,5 +1,5 @@import { ActionButton } from "@/src/components/ActionButton";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { BadgeCheck, X } from "@langfuse/icons";import { useRef } from "react";import type { ToastOperation } from "./toastAnalytics";diff --git a/web/src/features/notifications/components/PersonalNotificationSettings.tsx b/web/src/features/notifications/components/PersonalNotificationSettings.tsxindex ecf21fe5dc..37c329bf34 100644--- a/web/src/features/notifications/components/PersonalNotificationSettings.tsx+++ b/web/src/features/notifications/components/PersonalNotificationSettings.tsx@@ -4,7 +4,7 @@ import { api } from "@/src/utils/api";import Header from "@/src/components/layouts/header";import { Label } from "@/src/components/ui/label";import { Switch } from "@/src/components/design-system/Switch/Switch";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export function PersonalNotificationSettings() {const router = useRouter();diff --git a/web/src/features/notifications/components/ProjectNotificationChannels.tsx b/web/src/features/notifications/components/ProjectNotificationChannels.tsxindex 353b04fe12..335b7e4368 100644--- a/web/src/features/notifications/components/ProjectNotificationChannels.tsx+++ b/web/src/features/notifications/components/ProjectNotificationChannels.tsx@@ -11,10 +11,8 @@ import {DialogTitle,} from "@/src/components/ui/dialog";import { Switch } from "@/src/components/design-system/Switch/Switch";-import {- AutomationForm,- WebhookSecretRender,-} from "@/src/features/automations";+import { AutomationForm } from "@/src/features/automations/components/AutomationForm";+import { WebhookSecretRender } from "@/src/features/automations/components/WebhookSecretRender";import { ProjectNotificationChannelsList } from "@/src/features/notifications/components/ProjectNotificationChannelsList";import { useProjectNotificationChannels } from "@/src/features/notifications/hooks/useProjectNotificationChannels";import { cn } from "@/src/utils/tailwind";diff --git a/web/src/features/notifications/index.ts b/web/src/features/notifications/index.tsdeleted file mode 100644index db7cc86cbd..0000000000--- a/web/src/features/notifications/index.ts+++ /dev/null@@ -1,13 +0,0 @@-// The notifications feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported, nothing-// added for the future.-//-// Settings components stay a page-level deep import. Intra-feature modules-// (`ErrorNotification`, `SuccessNotification`, hooks) stay internal.--export { showErrorToast } from "@/src/features/notifications/showErrorToast";-export { showSuccessToast } from "@/src/features/notifications/showSuccessToast";-export {- showToast,- showCustomToast,-} from "@/src/features/notifications/showToast";diff --git a/web/src/features/notifications/showToast.clienttest.tsx b/web/src/features/notifications/showToast.clienttest.tsxindex e67d20fc18..e2af28fd49 100644--- a/web/src/features/notifications/showToast.clienttest.tsx+++ b/web/src/features/notifications/showToast.clienttest.tsx@@ -1,7 +1,10 @@import { StrictMode, type ReactNode } from "react";import { render, screen, waitFor } from "@testing-library/react";import { vi } from "vitest";-import { showCustomToast, showToast } from "@/src/features/notifications";+import {+ showCustomToast,+ showToast,+} from "@/src/features/notifications/showToast";vi.mock("@/src/features/notifications/showErrorToast", () => ({showErrorToast: vi.fn(),@@ -47,7 +50,7 @@ vi.mock("sonner", () => ({},}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => mocks.capture,}));diff --git a/web/src/features/notifications/showToast.tsx b/web/src/features/notifications/showToast.tsxindex 06a3ba356b..dbc645777c 100644--- a/web/src/features/notifications/showToast.tsx+++ b/web/src/features/notifications/showToast.tsx@@ -1,7 +1,7 @@/* eslint-disable @typescript-eslint/no-use-before-define */import { toast, type ExternalToast } from "sonner";import { useRef, type ReactNode } from "react";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {getToastErrorProperties,type ToastErrorAnalytics,diff --git a/web/src/features/onboarding/components/ConnectedOnboardingSurvey.clienttest.tsx b/web/src/features/onboarding/components/ConnectedOnboardingSurvey.clienttest.tsxindex 2cc8c51f08..6e980e0565 100644--- a/web/src/features/onboarding/components/ConnectedOnboardingSurvey.clienttest.tsx+++ b/web/src/features/onboarding/components/ConnectedOnboardingSurvey.clienttest.tsx@@ -56,15 +56,15 @@ vi.mock("next-auth/react", () => ({}),}));-vi.mock("@/src/features/organizations", () => ({+vi.mock("@/src/features/organizations/hooks", () => ({useLangfuseCloudRegion: () => ({ isLangfuseCloud: harness.isLangfuseCloud }),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));-vi.mock("@/src/features/notifications", () => ({+vi.mock("@/src/features/notifications/showErrorToast", () => ({showErrorToast: (...args: unknown[]) => showErrorToastMock(...args),}));diff --git a/web/src/features/onboarding/components/ConnectedOnboardingSurvey.tsx b/web/src/features/onboarding/components/ConnectedOnboardingSurvey.tsxindex 82eae3eef8..2eff0c601f 100644--- a/web/src/features/onboarding/components/ConnectedOnboardingSurvey.tsx+++ b/web/src/features/onboarding/components/ConnectedOnboardingSurvey.tsx@@ -2,9 +2,9 @@ import { useCallback, useEffect, useState } from "react";import { useRouter } from "next/router";import { useSession } from "next-auth/react";import { env } from "@/src/env.mjs";-import { showErrorToast } from "@/src/features/notifications";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useWatchedPromiseCallback } from "@/src/hooks/useWatchedPromiseCallback";import { api, type RouterInputs, type RouterOutputs } from "@/src/utils/api";import { reportError } from "@/src/utils/reportError";diff --git a/web/src/features/onboarding/server/index.ts b/web/src/features/onboarding/server/index.tsdeleted file mode 100644index 57ef325611..0000000000--- a/web/src/features/onboarding/server/index.ts+++ /dev/null@@ -1,8 +0,0 @@-export {- completeSignupOnboarding,- getSignupOnboardingStatus,- isSignupOnboardingEnabled,- provisionStarterOrganizationForNewUser,- resolveOnboardingRedirectTarget,- type RealOrganizationMembership,-} from "@/src/features/onboarding/server/onboardingService";diff --git a/web/src/features/onboarding/server/onboardingService.ts b/web/src/features/onboarding/server/onboardingService.tsindex 25e8a768e3..165d095f0f 100644--- a/web/src/features/onboarding/server/onboardingService.ts+++ b/web/src/features/onboarding/server/onboardingService.ts@@ -10,13 +10,14 @@ import {invalidateCachedOrgApiKeys,} from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {organizationRoleAccessRights,type OrganizationScope,-} from "@/src/features/rbac";+} from "@langfuse/shared/rbac";+import { projectRoleAccessRights } from "@langfuse/shared";-import { createProjectRoute } from "@/src/features/setup";+import { createProjectRoute } from "@/src/features/setup/setupRoutes";import { type BuildIntentId } from "@/src/features/onboarding/lib/buildIntent";import { getFallbackRedirectPath } from "@/src/features/onboarding/lib/fallbackRedirect";import {diff --git a/web/src/features/orderBy/index.ts b/web/src/features/orderBy/index.tsdeleted file mode 100644index d9ea9e75b2..0000000000--- a/web/src/features/orderBy/index.ts+++ /dev/null@@ -1,4 +0,0 @@-// The orderBy feature's public client surface (RFC rule 8). Named-// re-exports only — the table sort hook other features already imported-// by file path.-export { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";diff --git a/web/src/features/organization-usage/components/OrganizationUsageBreakdown.tsx b/web/src/features/organization-usage/components/OrganizationUsageBreakdown.tsxindex cef2797767..be4a635a3c 100644--- a/web/src/features/organization-usage/components/OrganizationUsageBreakdown.tsx+++ b/web/src/features/organization-usage/components/OrganizationUsageBreakdown.tsx@@ -8,11 +8,9 @@ import { Tabs } from "@/src/components/design-system/Tabs/Tabs";import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";import { TimeRangePicker } from "@/src/components/date-picker";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";-import {- downloadChartDataCsv,- VerticalBarChartTimeSeries,- type DataPoint,-} from "@/src/features/widgets";+import { downloadChartDataCsv } from "@/src/features/widgets/chart-library/downloadChartDataCsv";+import { VerticalBarChartTimeSeries } from "@/src/features/widgets/chart-library/VerticalBarChartTimeSeries";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";import { USAGE_BREAKDOWN_MAX_RANGE_MS } from "@/src/features/organization-usage/constants/usageBreakdown";import { api } from "@/src/utils/api";import { numberFormatter } from "@/src/utils/numbers";diff --git a/web/src/features/organization-usage/index.ts b/web/src/features/organization-usage/index.tsdeleted file mode 100644index 71c47d55a0..0000000000--- a/web/src/features/organization-usage/index.ts+++ /dev/null@@ -1,3 +0,0 @@-// The organization-usage feature's public client surface (RFC rule 8).-// organizationUsageRouter stays a direct import from the tRPC root.-export { OrganizationUsageBreakdown } from "@/src/features/organization-usage/components/OrganizationUsageBreakdown";diff --git a/web/src/features/organization-usage/server/organizationUsageRouter.ts b/web/src/features/organization-usage/server/organizationUsageRouter.tsindex 34b63c2e07..9865b94383 100644--- a/web/src/features/organization-usage/server/organizationUsageRouter.ts+++ b/web/src/features/organization-usage/server/organizationUsageRouter.ts@@ -1,6 +1,6 @@import * as z from "zod";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import {createTRPCRouter,protectedOrganizationProcedure,diff --git a/web/src/features/organizations/OrganizationSettingsPage.tsx b/web/src/features/organizations/OrganizationSettingsPage.tsxindex aaa475bfe7..e0badd4d79 100644--- a/web/src/features/organizations/OrganizationSettingsPage.tsx+++ b/web/src/features/organizations/OrganizationSettingsPage.tsx@@ -4,34 +4,32 @@ import { Button } from "@/src/components/ui/button";import { InfoTooltip } from "@/src/components/ui/InfoTooltip/InfoTooltip";import { ConnectedMembershipInvitesSettingsTable } from "@/src/features/rbac/components/MembershipInvitesSettingsTable/ConnectedMembershipInvitesSettingsTable";import { ConnectedMembersSettingsTable } from "@/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { JSONView } from "@/src/components/ui/CodeJsonViewer";import { Card } from "@/src/components/ui/card";import RenameOrganization from "@/src/features/organizations/components/RenameOrganization";import { DeleteOrganizationDialogController } from "@/src/features/organizations/components/DeleteOrganizationDialogController";import { SettingsDangerZone } from "@/src/components/SettingsDangerZone";import { BillingSettings } from "@/src/ee/features/billing/components/BillingSettings";-import { OrganizationUsageBreakdown } from "@/src/features/organization-usage";-import { useHasEntitlement, usePlan } from "@/src/features/entitlements";-import { SSOSettings } from "@/src/ee/features/sso-settings";+import { OrganizationUsageBreakdown } from "@/src/features/organization-usage/components/OrganizationUsageBreakdown";+import { useHasEntitlement, usePlan } from "@/src/features/entitlements/hooks";+import { SSOSettings } from "@/src/ee/features/sso-settings/components/SSOSettings";import { type CloudConfigSchema, isCloudPlan } from "@langfuse/shared";import { Building2 } from "@langfuse/icons";-import { useQueryProjectOrOrganization } from "@/src/features/projects";-import { LlmConnectionEmptyState } from "@/src/features/public-api";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { LlmConnectionEmptyState } from "@/src/features/public-api/components/LlmConnectionEmptyState/LlmConnectionEmptyState";import { ApiKeyList } from "@/src/features/public-api/components/ApiKeyList";import AIFeatureSwitch from "@/src/features/organizations/components/AIFeatureSwitch";-import { useIsCloudBillingAvailable } from "@/src/ee/features/billing";+import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";import { env } from "@/src/env.mjs";-import { OrgAuditLogsSettingsPage } from "@/src/ee/features/audit-log-viewer";+import { OrgAuditLogsSettingsPage } from "@/src/ee/features/audit-log-viewer/OrgAuditLogsSettingsPage";import { useV4UpgradeUiFlag } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { OrganizationFeaturePreviewsSettings } from "@/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings";-import {- GatewayAnalyticsPage,- GatewayApiKeysPage,- GatewayModelsPage,- GatewayNotDeployedNotice,- GatewaySetupPage,-} from "@/src/features/ai-gateway";+import { GatewayAnalyticsPage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/GatewayAnalyticsPage";+import { GatewayNotDeployedNotice } from "@/src/features/ai-gateway/components/GatewayNotDeployedNotice/GatewayNotDeployedNotice";+import { GatewaySetupPage } from "@/src/features/ai-gateway/components/GatewaySetupPage/GatewaySetupPage";+import { GatewayApiKeysPage } from "@/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage";+import { GatewayModelsPage } from "@/src/features/ai-gateway/components/GatewayModelsPage/GatewayModelsPage";import { useGatewaySettingsAccess } from "@/src/features/ai-gateway/hooks/useGatewaySettingsAccess";import { useGatewayKeyReminder } from "@/src/features/ai-gateway/hooks/useGatewayKeyReminder";import useSessionStorage from "@/src/components/useSessionStorage";diff --git a/web/src/features/organizations/components/AIFeatureSwitch.tsx b/web/src/features/organizations/components/AIFeatureSwitch.tsxindex b8e21740e5..456d0e5be6 100644--- a/web/src/features/organizations/components/AIFeatureSwitch.tsx+++ b/web/src/features/organizations/components/AIFeatureSwitch.tsx@@ -1,5 +1,5 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { Button } from "@/src/components/ui/button";import { Switch } from "@/src/components/design-system/Switch/Switch";import { api } from "@/src/utils/api";@@ -13,7 +13,7 @@ import {DialogTitle,} from "@/src/components/ui/dialog";import Header from "@/src/components/layouts/header";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {useLangfuseCloudRegion,useQueryOrganization,diff --git a/web/src/features/organizations/components/AIFeaturesDisabledNotice.tsx b/web/src/features/organizations/components/AIFeaturesDisabledNotice.tsxindex ea41e7b3fb..5f45f274b9 100644--- a/web/src/features/organizations/components/AIFeaturesDisabledNotice.tsx+++ b/web/src/features/organizations/components/AIFeaturesDisabledNotice.tsx@@ -2,7 +2,7 @@ import { type ReactNode } from "react";import { ExternalLink } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";export function openAIFeaturesSettings(organizationId: string) {window.open(diff --git a/web/src/features/organizations/components/ConnectedNewOrganizationForm.tsx b/web/src/features/organizations/components/ConnectedNewOrganizationForm.tsxindex 387ab40123..b49e57442a 100644--- a/web/src/features/organizations/components/ConnectedNewOrganizationForm.tsx+++ b/web/src/features/organizations/components/ConnectedNewOrganizationForm.tsx@@ -1,7 +1,7 @@import type * as z from "zod";import { useSession } from "next-auth/react";import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import type { organizationFormSchema } from "@/src/features/organizations/utils/organizationNameSchema";import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";import { NewOrganizationForm } from "./NewOrganizationForm";diff --git a/web/src/features/organizations/components/DeleteOrganizationDialogController.clienttest.tsx b/web/src/features/organizations/components/DeleteOrganizationDialogController.clienttest.tsxindex 8c6948cc16..b7f622abd1 100644--- a/web/src/features/organizations/components/DeleteOrganizationDialogController.clienttest.tsx+++ b/web/src/features/organizations/components/DeleteOrganizationDialogController.clienttest.tsx@@ -34,15 +34,15 @@ vi.mock("@/src/features/organizations/hooks", () => ({useQueryOrganization: () => ({ id: "org-1", name: "Acme", projects: [] }),}));-vi.mock("@/src/features/rbac", () => ({+vi.mock("@/src/features/rbac/utils/checkOrganizationAccess", () => ({useHasOrganizationAccess: () => true,}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));-vi.mock("@/src/features/notifications", () => ({+vi.mock("@/src/features/notifications/showSuccessToast", () => ({showSuccessToast: mocks.showSuccessToast,}));diff --git a/web/src/features/organizations/components/DeleteOrganizationDialogController.tsx b/web/src/features/organizations/components/DeleteOrganizationDialogController.tsxindex 26c3424abd..cc3adec149 100644--- a/web/src/features/organizations/components/DeleteOrganizationDialogController.tsx+++ b/web/src/features/organizations/components/DeleteOrganizationDialogController.tsx@@ -1,14 +1,14 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { type ReactNode, useState } from "react";import { useRouter } from "next/router";import { useSession } from "next-auth/react";import { Dialog, DialogContent } from "@/src/components/ui/dialog";import { DeleteOrganizationDialogContent } from "@/src/features/organizations/components/DeleteOrganizationDialogContent";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useQueryOrganization } from "@/src/features/organizations/hooks";-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { api, reportNonTrpcError } from "@/src/utils/api";type DeleteOrganizationDialogControllerProps = {diff --git a/web/src/features/organizations/components/OrganizationProjectOverview.tsx b/web/src/features/organizations/components/OrganizationProjectOverview.tsxindex cbc2ba5e8b..e83c0b67e7 100644--- a/web/src/features/organizations/components/OrganizationProjectOverview.tsx+++ b/web/src/features/organizations/components/OrganizationProjectOverview.tsx@@ -25,7 +25,7 @@ import { Input } from "@/src/components/ui/input";import {hasOrganizationAccess,useHasOrganizationAccess,-} from "@/src/features/rbac";+} from "@/src/features/rbac/utils/checkOrganizationAccess";import { env } from "@/src/env.mjs";import { Fragment, type ReactNode } from "react";import { useRouter } from "next/router";@@ -33,12 +33,12 @@ import { useSession } from "next-auth/react";import {createOrganizationRoute,createProjectRoute,-} from "@/src/features/setup";+} from "@/src/features/setup/setupRoutes";import { isCloudPlan, planLabels } from "@langfuse/shared";import ContainerPage from "@/src/components/layouts/ContainerPage";import { type Session } from "next-auth";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { AgentToolsBanner } from "@/src/features/developer-tools";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { AgentToolsBanner } from "@/src/features/developer-tools/components/AgentToolsBanner";import {V4MigrationBanner,useV4MigrationBannerState,diff --git a/web/src/features/organizations/components/RenameOrganization.tsx b/web/src/features/organizations/components/RenameOrganization.tsxindex 95b4625510..678ce24034 100644--- a/web/src/features/organizations/components/RenameOrganization.tsx+++ b/web/src/features/organizations/components/RenameOrganization.tsx@@ -1,4 +1,4 @@-import { useHasOrganizationAccess } from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { Button } from "@/src/components/ui/button";import { Input } from "@/src/components/ui/input";import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";@@ -12,9 +12,9 @@ import {FormItem,FormMessage,} from "@/src/components/ui/form";-import { projectNameSchema } from "@/src/features/auth";+import { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";import Header from "@/src/components/layouts/header";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useQueryOrganization } from "@/src/features/organizations/hooks";import { Card } from "@/src/components/ui/card";import { LockIcon } from "@langfuse/icons";diff --git a/web/src/features/organizations/index.ts b/web/src/features/organizations/index.tsdeleted file mode 100644index 3a7e7d9b0c..0000000000--- a/web/src/features/organizations/index.ts+++ /dev/null@@ -1,31 +0,0 @@-// The organizations feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported from this-// feature's client modules.-//-// `server/` is a separate door. organizationsRouter stays a direct import-// from the tRPC root. canCreateOrganizations, organizationNameSchema, and-// buildAdminOrgContext live on `server/index.ts` so this client barrel-// never reaches auth/onboarding.-//-// ConnectedNewOrganizationForm, OrganizationProjectOverview, and-// useOrganizationSettingsPages stay off this door. The barrel is already-// imported by projects/hooks (useQueryOrganization); adding the settings-// page would pull ai-gateway and search-bar into every useQueryProject-// consumer, including filter-builder on the filters door that-// ComposerTokens already imports.-export {- getAvailableCloudRegionOptions,- getCloudRegionAuthUrl,- isRegionProduction,- type CloudRegion,- type CloudRegionName,-} from "@/src/features/organizations/cloudRegions";-export {- AIFeaturesDisabledNotice,- openAIFeaturesSettings,-} from "@/src/features/organizations/components/AIFeaturesDisabledNotice";-export {- useLangfuseCloudRegion,- useLangfuseV4WriteMode,- useQueryOrganization,-} from "@/src/features/organizations/hooks";diff --git a/web/src/features/organizations/server/adminOrgContext.ts b/web/src/features/organizations/server/adminOrgContext.tsindex ecc96559df..fe21f966c3 100644--- a/web/src/features/organizations/server/adminOrgContext.ts+++ b/web/src/features/organizations/server/adminOrgContext.ts@@ -1,7 +1,7 @@import { CloudConfigSchema } from "@langfuse/shared";import { isTopicsProjectEnabled } from "@langfuse/shared/topics/server";import { Role, type PrismaClient } from "@langfuse/shared/src/db";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import { type Session } from "next-auth";import { TRPCError } from "@trpc/server";diff --git a/web/src/features/organizations/server/canCreateOrganizations.ts b/web/src/features/organizations/server/canCreateOrganizations.tsindex 19ced26c93..e66fac723e 100644--- a/web/src/features/organizations/server/canCreateOrganizations.ts+++ b/web/src/features/organizations/server/canCreateOrganizations.ts@@ -1,8 +1,6 @@import { env } from "@/src/env.mjs";-import {- getSelfHostedInstancePlanServerSide,- hasEntitlementBasedOnPlan,-} from "@/src/features/entitlements/server";+import { getSelfHostedInstancePlanServerSide } from "@/src/features/entitlements/server/getPlan";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";export function canCreateOrganizations(userEmail: string | null): boolean {const instancePlan = getSelfHostedInstancePlanServerSide();diff --git a/web/src/features/organizations/server/index.ts b/web/src/features/organizations/server/index.tsdeleted file mode 100644index 15694984af..0000000000--- a/web/src/features/organizations/server/index.ts+++ /dev/null@@ -1,6 +0,0 @@-// The organizations feature's public server surface (RFC rules 8 and 10).-// organizationsRouter stays a direct import from the tRPC root, which is-// not a feature.-export { buildAdminOrgContext } from "@/src/features/organizations/server/adminOrgContext";-export { canCreateOrganizations } from "@/src/features/organizations/server/canCreateOrganizations";-export { organizationNameSchema } from "@/src/features/organizations/utils/organizationNameSchema";diff --git a/web/src/features/organizations/server/organizationRouter.ts b/web/src/features/organizations/server/organizationRouter.tsindex d1ca410a9d..b4be6be031 100644--- a/web/src/features/organizations/server/organizationRouter.ts+++ b/web/src/features/organizations/server/organizationRouter.ts@@ -3,34 +3,32 @@ import {protectedOrganizationProcedure,authenticatedProcedure,} from "@/src/server/api/trpc";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {organizationFormSchema,organizationOptionalNameSchema,} from "@/src/features/organizations/utils/organizationNameSchema";import * as z from "zod";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { TRPCError } from "@trpc/server";-import { ApiAuthService } from "@/src/features/public-api/server";+import { ApiAuthService } from "@/src/features/public-api/server/apiAuth";import {getLastTraceTimestampsByProjects,isLangfuseAITracingConfigured,redis,} from "@langfuse/shared/src/server";-import {- isCloudBillingEnabled,- resolveBillingService,-} from "@/src/ee/features/billing/server";-import { shouldAutoEnableV4 } from "@/src/features/events/server";+import { isCloudBillingEnabled } from "@/src/ee/features/billing/utils/isCloudBillingEnabled";+import { resolveBillingService } from "@/src/ee/features/billing/server/resolveBillingService";+import { shouldAutoEnableV4 } from "@/src/features/events/lib/v4Rollout";import { buildAdminOrgContext } from "@/src/features/organizations/server/adminOrgContext";-import { getSfdcService } from "@/src/ee/features/sfdc-sync/server";+import { getSfdcService } from "@/src/ee/features/sfdc-sync/server/sfdcService";import {featurePreviewFlags,- getOrganizationFeaturePreviewDefaults,isOrganizationOnlyFeaturePreviewFlag,- setOrganizationFeatureFlagDefault,- parseFlags,-} from "@/src/features/feature-flags/server";+} from "@/src/features/feature-flags/available-flags";+import { getOrganizationFeaturePreviewDefaults } from "@/src/features/feature-flags/fns/getOrganizationFeaturePreviewDefaults";+import { setOrganizationFeatureFlagDefault } from "@/src/features/feature-flags/server/organizationFeatureFlags";+import { parseFlags } from "@/src/features/feature-flags/server/parseFlags";import { env } from "@/src/env.mjs";export const organizationsRouter = createTRPCRouter({diff --git a/web/src/features/pagerduty/hooks/usePagerDutyTestEvent.ts b/web/src/features/pagerduty/hooks/usePagerDutyTestEvent.tsindex 5ff1ed0ddf..14ca014879 100644--- a/web/src/features/pagerduty/hooks/usePagerDutyTestEvent.ts+++ b/web/src/features/pagerduty/hooks/usePagerDutyTestEvent.ts@@ -1,8 +1,8 @@import { useState } from "react";import { type PagerDutyRegion } from "@langfuse/shared/pagerduty";-import { showSuccessToast } from "@/src/features/notifications";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";/** usePagerDutyTestEvent triggers a critical test alert for the project and resolves it once it is open. */diff --git a/web/src/features/pagerduty/index.ts b/web/src/features/pagerduty/index.tsdeleted file mode 100644index 6dcd4fff48..0000000000--- a/web/src/features/pagerduty/index.ts+++ /dev/null@@ -1,6 +0,0 @@-export { PagerDutyActionForm } from "@/src/features/pagerduty/components/PagerDutyActionForm";-export { PagerDutyTestEventButtonsView } from "@/src/features/pagerduty/components/PagerDutyTestEventButtonsView";-export {- usePagerDutyTestEvent,- type PagerDutyTestEventState,-} from "@/src/features/pagerduty/hooks/usePagerDutyTestEvent";diff --git a/web/src/features/pagerduty/server/index.ts b/web/src/features/pagerduty/server/index.tsdeleted file mode 100644index 81b6a95608..0000000000--- a/web/src/features/pagerduty/server/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export {- processPagerDutyActionConfig,- sendPagerDutyTestEvent,-} from "@/src/features/pagerduty/server/pagerdutyHelpers";diff --git a/web/src/features/payment-banner/PaymentBanner.tsx b/web/src/features/payment-banner/PaymentBanner.tsxindex ac1ad02647..e5e416ced3 100644--- a/web/src/features/payment-banner/PaymentBanner.tsx+++ b/web/src/features/payment-banner/PaymentBanner.tsx@@ -1,9 +1,9 @@import { useMemo } from "react";import { useSession } from "next-auth/react";-import { useQueryProjectOrOrganization } from "@/src/features/projects";-import { useIsCloudBillingAvailable } from "@/src/ee/features/billing";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";import { env } from "@/src/env.mjs";-import { hasOrganizationAccess } from "@/src/features/rbac";+import { hasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";export function usePaymentBanner() {const session = useSession();diff --git a/web/src/features/payment-banner/index.ts b/web/src/features/payment-banner/index.tsdeleted file mode 100644index f65b2b6f50..0000000000--- a/web/src/features/payment-banner/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { usePaymentBanner } from "./PaymentBanner";-export { PaymentBannerView } from "./PaymentBannerView";diff --git a/web/src/features/playground/index.ts b/web/src/features/playground/index.tsdeleted file mode 100644index 6dc20defed..0000000000--- a/web/src/features/playground/index.ts+++ /dev/null@@ -1,6 +0,0 @@-// The playground feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export { CreateOrEditLLMSchemaDialog } from "@/src/features/playground/page/components/CreateOrEditLLMSchemaDialog";-export { JumpToPlaygroundDropdownMenuController } from "@/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController";-export { useModelParams } from "@/src/features/playground/page/hooks/useModelParams";-export { default as usePlaygroundCache } from "@/src/features/playground/page/hooks/usePlaygroundCache";diff --git a/web/src/features/playground/page/PlaygroundPage.tsx b/web/src/features/playground/page/PlaygroundPage.tsxindex ee6423fa45..a9e1ca2355 100644--- a/web/src/features/playground/page/PlaygroundPage.tsx+++ b/web/src/features/playground/page/PlaygroundPage.tsx@@ -10,10 +10,8 @@ import { type MultiWindowState } from "@/src/features/playground/page/types";import Page from "@/src/components/layouts/Page";import MultiWindowPlayground from "@/src/features/playground/page/components/MultiWindowPlayground";import { NoModelConfiguredAlert } from "@/src/features/playground/page/components/NoModelConfiguredAlert";-import {- MessageSearchProvider,- MessageSearchToolbar,-} from "@/src/components/ChatMessages/MessageSearch";+import { MessageSearchProvider } from "@/src/components/ChatMessages/messageSearch/context";+import { MessageSearchToolbar } from "@/src/components/ChatMessages/messageSearch/toolbar";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { Spinner } from "@/src/components/design-system/Spinner/Spinner";diff --git a/web/src/features/playground/page/components/CreateOrEditLLMSchemaDialog.tsx b/web/src/features/playground/page/components/CreateOrEditLLMSchemaDialog.tsxindex 9d43a35ac3..5db1681da0 100644--- a/web/src/features/playground/page/components/CreateOrEditLLMSchemaDialog.tsx+++ b/web/src/features/playground/page/components/CreateOrEditLLMSchemaDialog.tsx@@ -26,12 +26,12 @@ import {} from "@/src/components/ui/form";import { Input } from "@/src/components/ui/input";import { Textarea } from "@/src/components/ui/textarea";-import { LLMSchemaNameSchema } from "@/src/features/llm-schemas";+import { LLMSchemaNameSchema } from "@/src/features/llm-schemas/validation";import { api } from "@/src/utils/api";import { JSONSchemaFormSchema, type LlmSchema } from "@langfuse/shared";-import { CodeMirrorEditor } from "@/src/components/editor";-import { showErrorToast } from "@/src/features/notifications";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";const formSchema = z.object({name: LLMSchemaNameSchema,diff --git a/web/src/features/playground/page/components/CreateOrEditLLMToolDialog.tsx b/web/src/features/playground/page/components/CreateOrEditLLMToolDialog.tsxindex 441cb84aab..c775c55ef6 100644--- a/web/src/features/playground/page/components/CreateOrEditLLMToolDialog.tsx+++ b/web/src/features/playground/page/components/CreateOrEditLLMToolDialog.tsx@@ -26,12 +26,12 @@ import {} from "@/src/components/ui/form";import { Input } from "@/src/components/ui/input";import { Textarea } from "@/src/components/ui/textarea";-import { LLMToolNameSchema } from "@/src/features/llm-tools";+import { LLMToolNameSchema } from "@/src/features/llm-tools/validation";import { api } from "@/src/utils/api";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { JSONSchemaFormSchema, type LlmTool } from "@langfuse/shared";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";const formSchema = z.object({name: LLMToolNameSchema,diff --git a/web/src/features/playground/page/components/GenerationOutput.tsx b/web/src/features/playground/page/components/GenerationOutput.tsxindex 87b73d7f80..09eb151519 100644--- a/web/src/features/playground/page/components/GenerationOutput.tsx+++ b/web/src/features/playground/page/components/GenerationOutput.tsx@@ -5,7 +5,7 @@ import { ChatMessageRole, ChatMessageType } from "@langfuse/shared";import { BracesIcon, Check, Copy, Plus } from "@langfuse/icons";import { ToolCallCard } from "@/src/components/ChatMessages/ToolCallCard";import { copyTextToClipboard } from "@/src/utils/clipboard";-import { ThinkingBlock } from "@/src/features/traces";+import { ThinkingBlock } from "@/src/features/traces/components/ThinkingBlock";export const GenerationOutput = () => {const [isCopied, setIsCopied] = useState(false);diff --git a/web/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController.tsx b/web/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController.tsxindex 9387400be8..332274fb96 100644--- a/web/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController.tsx+++ b/web/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController.tsx@@ -23,7 +23,7 @@ import {getWindowState,setWindowState,} from "@/src/features/playground/page/storage/windowStorage";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import {ChatMessageRole,@@ -39,8 +39,10 @@ import {type PlaceholderMessage,PromptType,isGenerationLike,+ normalizeInput,+ normalizeOutput,} from "@langfuse/shared";-import { normalizeInput, normalizeOutput } from "@/src/utils/chatml";+import { extractTools } from "@/src/utils/chatml/extractTools";import { convertChatMlToPlayground } from "@/src/utils/chatml/playgroundConverter";import { api } from "@/src/utils/api";diff --git a/web/src/features/playground/page/components/MessagePlaceholderComponent.tsx b/web/src/features/playground/page/components/MessagePlaceholderComponent.tsxindex cafb892c93..1fbc491eb7 100644--- a/web/src/features/playground/page/components/MessagePlaceholderComponent.tsx+++ b/web/src/features/playground/page/components/MessagePlaceholderComponent.tsx@@ -1,6 +1,6 @@import { CheckCircle2, Circle, TrashIcon } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { useState, useCallback } from "react";import { type ChatMessage } from "@langfuse/shared";diff --git a/web/src/features/playground/page/components/MultiWindowPlayground.tsx b/web/src/features/playground/page/components/MultiWindowPlayground.tsxindex fbf1a6db7a..e0e73f8572 100644--- a/web/src/features/playground/page/components/MultiWindowPlayground.tsx+++ b/web/src/features/playground/page/components/MultiWindowPlayground.tsx@@ -12,7 +12,7 @@ import { MULTI_WINDOW_CONFIG, type MultiWindowState } from "../types";import { ModelParameters } from "@/src/components/ModelParameters";import { Messages } from "@/src/features/playground/page/components/Messages";import { ConfigurationDropdowns } from "@/src/features/playground/page/components/ConfigurationDropdowns";-import { useMessageSearchActions } from "@/src/components/ChatMessages/MessageSearch";+import { useMessageSearchActions } from "@/src/components/ChatMessages/messageSearch/context";import {Tooltip,TooltipContent,diff --git a/web/src/features/playground/page/components/PromptVariableComponent.tsx b/web/src/features/playground/page/components/PromptVariableComponent.tsxindex 7614ccb07c..5290466174 100644--- a/web/src/features/playground/page/components/PromptVariableComponent.tsx+++ b/web/src/features/playground/page/components/PromptVariableComponent.tsx@@ -1,7 +1,7 @@import { CheckCircle2, Circle, TrashIcon } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";import { type PromptVariable } from "@langfuse/shared";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { usePlaygroundContext } from "../context/PlaygroundProvider";import { useNamingConflicts } from "../hooks/useNamingConflicts";diff --git a/web/src/features/playground/page/components/SaveToPromptButton.tsx b/web/src/features/playground/page/components/SaveToPromptButton.tsxindex cf48474218..93e3f7bbcc 100644--- a/web/src/features/playground/page/components/SaveToPromptButton.tsx+++ b/web/src/features/playground/page/components/SaveToPromptButton.tsx@@ -25,7 +25,7 @@ import {} from "@/src/components/ui/tooltip";import { usePlaygroundContext } from "@/src/features/playground/page/context/PlaygroundProvider";import usePlaygroundCache from "@/src/features/playground/page/hooks/usePlaygroundCache";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { api } from "@/src/utils/api";import { cn } from "@/src/utils/tailwind";diff --git a/web/src/features/playground/page/context/PlaygroundProvider.tsx b/web/src/features/playground/page/context/PlaygroundProvider.tsxindex 11abd148ca..ada8343d0e 100644--- a/web/src/features/playground/page/context/PlaygroundProvider.tsx+++ b/web/src/features/playground/page/context/PlaygroundProvider.tsx@@ -1,4 +1,4 @@-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import React, {createContext,useCallback,@@ -13,7 +13,7 @@ import { v4 as uuidv4 } from "uuid";import { createEmptyMessage } from "@/src/components/ChatMessages/utils/createEmptyMessage";import { useModelParams } from "@/src/features/playground/page/hooks/useModelParams";import usePlaygroundCache from "@/src/features/playground/page/hooks/usePlaygroundCache";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import {ChatMessageRole,@@ -48,7 +48,7 @@ import {getPlaygroundEventBus,useWindowCoordination,} from "@/src/features/playground/page/hooks/useWindowCoordination";-import { useSyncMessageSearchMessages } from "@/src/components/ChatMessages/MessageSearch";+import { useSyncMessageSearchMessages } from "@/src/components/ChatMessages/messageSearch/context";import { getFinalModelParams } from "@/src/utils/getFinalModelParams";import { STREAMING_PREF_KEY } from "@/src/features/playground/page/storage/keys";import { captureUnknownError } from "@/src/utils/captureUnknownError";diff --git a/web/src/features/playground/page/hooks/usePersistedWindowIds.ts b/web/src/features/playground/page/hooks/usePersistedWindowIds.tsindex 6c24ece7bf..4e75f82d74 100644--- a/web/src/features/playground/page/hooks/usePersistedWindowIds.ts+++ b/web/src/features/playground/page/hooks/usePersistedWindowIds.ts@@ -8,7 +8,7 @@ import {removeWindowState,clearAllPlaygroundData,} from "../storage/windowStorage";-import { showToast } from "@/src/features/notifications";+import { showToast } from "@/src/features/notifications/showToast";/*** Hook to persist window IDs across page refreshes.diff --git a/web/src/features/playground/page/hooks/useWindowCoordination.ts b/web/src/features/playground/page/hooks/useWindowCoordination.tsindex e6f121666a..5a309192c4 100644--- a/web/src/features/playground/page/hooks/useWindowCoordination.ts+++ b/web/src/features/playground/page/hooks/useWindowCoordination.ts@@ -4,7 +4,7 @@ import {type WindowCoordinationReturn,PLAYGROUND_EVENTS,} from "../types";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";/*** Playground window registry for coordinating actions across multiple playground windowsdiff --git a/web/src/features/playground/server/authorizeRequest.ts b/web/src/features/playground/server/authorizeRequest.tsindex 2b1f8c8e02..5b38cce141 100644--- a/web/src/features/playground/server/authorizeRequest.ts+++ b/web/src/features/playground/server/authorizeRequest.ts@@ -1,7 +1,7 @@import { getServerAuthSessionForRequest } from "@/src/server/auth";import { isProjectMemberOrAdmin } from "@/src/server/utils/checkProjectMembershipOrAdmin";import { ForbiddenError, UnauthorizedError } from "@langfuse/shared";-import { hasProjectAccess } from "@/src/features/rbac";+import { hasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export type AuthorizeRequestResult = {userId: string;diff --git a/web/src/features/posthog-analytics/index.ts b/web/src/features/posthog-analytics/index.tsdeleted file mode 100644index 28157ef98b..0000000000--- a/web/src/features/posthog-analytics/index.ts+++ /dev/null@@ -1,23 +0,0 @@-// The product-analytics feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported from this-// feature's client modules, nothing added for the future.-//-// `ServerPosthog` stays a deep import. Re-exporting it here pulled-// `posthog-node` into every client that only needed the capture hook (Storybook-// and the Next web build both failed). Callers in `auth/lib` and `telemetry`-// are not under `server/`, so a `server/index.ts` is rule 10. Those two inbound-// paths remain until those callers move.-//-// `server/backendActivity` stays a direct import from the tRPC root, which is-// not a feature.--export {- usePostHogClientCapture,- V4_BETA_ENABLED_POSTHOG_PROPERTY,-} from "@/src/features/posthog-analytics/usePostHogClientCapture";--export {- getPostHogClientConfig,- isPostHogClientEnabled,- isProductAnalyticsAvailable,-} from "@/src/features/posthog-analytics/productAnalyticsAvailability";diff --git a/web/src/features/posthog-integration/PostHogIntegrationPage.tsx b/web/src/features/posthog-integration/PostHogIntegrationPage.tsxindex 37947a4e41..c1ad46f6fe 100644--- a/web/src/features/posthog-integration/PostHogIntegrationPage.tsx+++ b/web/src/features/posthog-integration/PostHogIntegrationPage.tsx@@ -4,7 +4,7 @@ import Header from "@/src/components/layouts/header";import ContainerPage from "@/src/components/layouts/ContainerPage";import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";import { Button } from "@/src/components/design-system/Button/Button";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { PostHogStatusSection } from "@/src/features/posthog-integration/components/PostHogStatusSection";import {PostHogIntegrationForm,@@ -19,10 +19,10 @@ import {import {buildExportSourceContext,getExportSourceFormValue,- IntegrationSettingsSkeleton,-} from "@/src/features/analytics-integrations";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useQueryProject } from "@/src/features/projects";+} from "@/src/features/analytics-integrations/exportSource";+import { IntegrationSettingsSkeleton } from "@/src/features/analytics-integrations/components/IntegrationSettingsSkeleton";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useQueryProject } from "@/src/features/projects/hooks";import { usePostHogIntegration } from "@/src/features/posthog-integration/usePostHogIntegration";import { api } from "@/src/utils/api";import { type RouterOutput } from "@/src/utils/types";diff --git a/web/src/features/posthog-integration/components/PostHogIntegrationForm.tsx b/web/src/features/posthog-integration/components/PostHogIntegrationForm.tsxindex eaa61f789f..c9c7662258 100644--- a/web/src/features/posthog-integration/components/PostHogIntegrationForm.tsx+++ b/web/src/features/posthog-integration/components/PostHogIntegrationForm.tsx@@ -20,7 +20,7 @@ import {getExportSourceFieldState,getExportSourceUnavailableMessage,isExportSourceSelectable,-} from "@/src/features/analytics-integrations";+} from "@/src/features/analytics-integrations/exportSource";import { posthogIntegrationFormSchema } from "@/src/features/posthog-integration/types";import { areDestinationUrlsEquivalent } from "@/src/features/automations/destinationUrl";diff --git a/web/src/features/posthog-integration/posthog-integration-router.ts b/web/src/features/posthog-integration/posthog-integration-router.tsindex ea3e0090ad..ce1faeabd3 100644--- a/web/src/features/posthog-integration/posthog-integration-router.ts+++ b/web/src/features/posthog-integration/posthog-integration-router.ts@@ -1,13 +1,16 @@import { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {assertPersistedExportSourceAllowed,resolveExportSource,+} from "@/src/features/analytics-integrations/server/exportSource";+import {isPrismaRecordNotFoundError,- getDisplayCredential,-} from "@/src/features/analytics-integrations/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+ validateWebhookURL,+} from "@langfuse/shared/src/server";+import { getDisplayCredential } from "@/src/features/analytics-integrations/server/displayCredential";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,@@ -16,7 +19,7 @@ import { decrypt, encrypt } from "@langfuse/shared/encryption";import { posthogIntegrationFormSchema } from "@/src/features/posthog-integration/types";import { TRPCError } from "@trpc/server";import { env } from "@/src/env.mjs";-import { validateWebhookURL } from "@langfuse/shared/src/server";+import { areDestinationUrlsEquivalent } from "@/src/features/automations/destinationUrl";import {AnalyticsIntegrationExportSource,diff --git a/web/src/features/posthog-integration/usePostHogIntegration.ts b/web/src/features/posthog-integration/usePostHogIntegration.tsindex 74c60d57c7..ee359428c4 100644--- a/web/src/features/posthog-integration/usePostHogIntegration.ts+++ b/web/src/features/posthog-integration/usePostHogIntegration.ts@@ -1,5 +1,5 @@import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";// A persisted fault outranks active/inactive: it is the state the admin hasdiff --git a/web/src/features/preview-deployment-banner/index.ts b/web/src/features/preview-deployment-banner/index.tsdeleted file mode 100644index 0a5341b127..0000000000--- a/web/src/features/preview-deployment-banner/index.ts+++ /dev/null@@ -1 +0,0 @@-export { PreviewDeploymentBanner } from "./PreviewDeploymentBanner";diff --git a/web/src/features/projects/ProjectSettingsPage.tsx b/web/src/features/projects/ProjectSettingsPage.tsxindex ceb5578fe0..e19b360dc0 100644--- a/web/src/features/projects/ProjectSettingsPage.tsx+++ b/web/src/features/projects/ProjectSettingsPage.tsx@@ -11,36 +11,34 @@ import { PagedSettingsContainer } from "@/src/components/PagedSettingsContainer"import { useQueryProject } from "@/src/features/projects/hooks";import { ConnectedMembershipInvitesSettingsTable } from "@/src/features/rbac/components/MembershipInvitesSettingsTable/ConnectedMembershipInvitesSettingsTable";import { ConnectedMembersSettingsTable } from "@/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable";-import {- useHasProjectAccess,- useHasOrganizationAccess,-} from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { JSONView } from "@/src/components/ui/CodeJsonViewer";import { PostHogLogo } from "@/src/components/PostHogLogo";import { MixpanelLogo } from "@/src/components/MixpanelLogo";import { Card } from "@/src/components/ui/card";import { TransferProjectDialogController } from "@/src/features/projects/components/TransferProjectDialogController";-import { useHasEntitlement } from "@/src/features/entitlements";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";import { useRouter } from "next/router";import { SettingsDangerZone } from "@/src/components/SettingsDangerZone";import { ActionButton } from "@/src/components/ActionButton";import { Webhook } from "@langfuse/icons";-import { BatchExportsSettingsPage } from "@/src/features/batch-exports";-import { BatchActionsSettingsPage } from "@/src/features/batch-actions";-import { AuditLogsSettingsPage } from "@/src/ee/features/audit-log-viewer";-import { ModelsSettings } from "@/src/features/models";+import { BatchExportsSettingsPage } from "@/src/features/batch-exports/components/BatchExportsSettingsPage";+import { BatchActionsSettingsPage } from "@/src/features/batch-actions/components/BatchActionsSettingsPage";+import { AuditLogsSettingsPage } from "@/src/ee/features/audit-log-viewer/AuditLogsSettingsPage";+import { ModelsSettings } from "@/src/features/models/components/ModelsSettings";import ConfigureRetention from "@/src/features/projects/components/ConfigureRetention";import ContainerPage from "@/src/components/layouts/ContainerPage";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";-import { ProtectedLabelsSettings } from "@/src/features/prompts";+import { default as ProtectedLabelsSettings } from "@/src/features/prompts/components/ProtectedLabelsSettings";import { SiSlack } from "@langfuse/icons/si";-import { ScoreConfigSettings } from "@/src/features/score-configs";+import { ScoreConfigSettings } from "@/src/features/score-configs/components/ScoreConfigSettings";import { env } from "@/src/env.mjs";import { PersonalNotificationSettings } from "@/src/features/notifications/components/PersonalNotificationSettings";import { ProjectNotificationChannels } from "@/src/features/notifications/components/ProjectNotificationChannels";import useSessionStorage from "@/src/components/useSessionStorage";-import { useWebCallouts } from "@/src/features/web-callouts";-import { DeveloperToolsSettings } from "@/src/features/developer-tools";+import { useWebCallouts } from "@/src/features/web-callouts/useWebCallouts";+import { DeveloperToolsSettings } from "@/src/features/developer-tools/components/DeveloperToolsSettings";import { useV4UpgradeUiFlag } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { api } from "@/src/utils/api";import {diff --git a/web/src/features/projects/components/ConfigureRetention.tsx b/web/src/features/projects/components/ConfigureRetention.tsxindex b493ab6594..0d1b0cb975 100644--- a/web/src/features/projects/components/ConfigureRetention.tsx+++ b/web/src/features/projects/components/ConfigureRetention.tsx@@ -13,14 +13,14 @@ import {FormMessage,} from "@/src/components/ui/form";import Header from "@/src/components/layouts/header";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { LockIcon } from "@langfuse/icons";import { useQueryProject } from "@/src/features/projects/hooks";import { useSession } from "next-auth/react";-import { useHasProjectAccess } from "@/src/features/rbac";-import { projectRetentionSchema } from "@/src/features/auth";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { projectRetentionSchema } from "@/src/features/auth/lib/projectRetentionSchema";import { ActionButton } from "@/src/components/ActionButton";-import { useHasEntitlement } from "@/src/features/entitlements";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";export default function ConfigureRetention() {const { update: updateSession } = useSession();diff --git a/web/src/features/projects/components/DeleteProjectDialogController/DeleteProjectDialogController.tsx b/web/src/features/projects/components/DeleteProjectDialogController/DeleteProjectDialogController.tsxindex 0a885efce0..12be366f19 100644--- a/web/src/features/projects/components/DeleteProjectDialogController/DeleteProjectDialogController.tsx+++ b/web/src/features/projects/components/DeleteProjectDialogController/DeleteProjectDialogController.tsx@@ -3,12 +3,10 @@ import { type ReactNode } from "react";import { Dialog } from "@/src/components/design-system/Dialog/Dialog";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { env } from "@/src/env.mjs";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useQueryProject } from "@/src/features/projects/hooks";-import {- useHasOrganizationAccess,- useHasProjectAccess,-} from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api, reportNonTrpcError } from "@/src/utils/api";import { DeleteProjectDialog } from "@/src/features/projects/components/DeleteProjectDialogController/components/DeleteProjectDialog/DeleteProjectDialog";diff --git a/web/src/features/projects/components/HostNameProject.tsx b/web/src/features/projects/components/HostNameProject.tsxindex a6fb567bb4..85e57761ce 100644--- a/web/src/features/projects/components/HostNameProject.tsx+++ b/web/src/features/projects/components/HostNameProject.tsx@@ -1,7 +1,7 @@import { Card } from "@/src/components/ui/card";import { CodeSection } from "@/src/components/design-system/CodeSection/CodeSection";import Header from "@/src/components/layouts/header";-import { useUiCustomization } from "@/src/ee/features/ui-customization";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import { env } from "@/src/env.mjs";export function HostNameProject() {diff --git a/web/src/features/projects/components/NewProjectForm.tsx b/web/src/features/projects/components/NewProjectForm.tsxindex f9dfcd8d91..81d8dc63bb 100644--- a/web/src/features/projects/components/NewProjectForm.tsx+++ b/web/src/features/projects/components/NewProjectForm.tsx@@ -13,8 +13,8 @@ import {import { Input } from "@/src/components/ui/input";import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";import { useSession } from "next-auth/react";-import { projectNameSchema } from "@/src/features/auth";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export const NewProjectForm = ({orgId,diff --git a/web/src/features/projects/components/RenameProject.tsx b/web/src/features/projects/components/RenameProject.tsxindex 6f8705a983..e2d64a09ac 100644--- a/web/src/features/projects/components/RenameProject.tsx+++ b/web/src/features/projects/components/RenameProject.tsx@@ -12,13 +12,13 @@ import {FormItem,FormMessage,} from "@/src/components/ui/form";-import { projectNameSchema } from "@/src/features/auth";+import { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";import Header from "@/src/components/layouts/header";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { LockIcon } from "@langfuse/icons";import { useQueryProject } from "@/src/features/projects/hooks";import { useSession } from "next-auth/react";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export default function RenameProject() {const { update: updateSession } = useSession();diff --git a/web/src/features/projects/components/TransferProjectDialogController.tsx b/web/src/features/projects/components/TransferProjectDialogController.tsxindex e7e9383669..cc5d2b8b03 100644--- a/web/src/features/projects/components/TransferProjectDialogController.tsx+++ b/web/src/features/projects/components/TransferProjectDialogController.tsx@@ -1,13 +1,13 @@-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { type ReactNode } from "react";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { TransferProjectDialog } from "@/src/features/projects/components/TransferProjectDialog";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {hasOrganizationAccess,useHasOrganizationAccess,-} from "@/src/features/rbac";+} from "@/src/features/rbac/utils/checkOrganizationAccess";import { api } from "@/src/utils/api";import { useSession } from "next-auth/react";diff --git a/web/src/features/projects/hooks.ts b/web/src/features/projects/hooks.tsindex 837dcaf11a..090d4ae0c6 100644--- a/web/src/features/projects/hooks.ts+++ b/web/src/features/projects/hooks.ts@@ -1,5 +1,5 @@/* eslint-disable @typescript-eslint/no-use-before-define */-import { useQueryOrganization } from "@/src/features/organizations";+import { useQueryOrganization } from "@/src/features/organizations/hooks";import { api } from "@/src/utils/api";import { useSession } from "next-auth/react";import { useRouter } from "next/router";diff --git a/web/src/features/projects/index.ts b/web/src/features/projects/index.tsdeleted file mode 100644index 28758bc748..0000000000--- a/web/src/features/projects/index.ts+++ /dev/null@@ -1,17 +0,0 @@-// The projects feature's public client surface (RFC rule 8). Named re-exports-// only — exactly the hooks other features already imported.-//-// useProjectSettingsPages stays off this door. CommandMenu and the settings-// page shims import it from ProjectSettingsPage: the barrel is already-// consumed by useQueryProject callers (including filter-builder on the-// filters door that ComposerTokens imports), and adding the settings page-// would pull that graph into every project-hook consumer.-//-// NewProjectForm stays a page-level deep import. projectsRouter stays a-// direct import from the tRPC root via server/index.ts.-export {- useOrgProjectSwitchPaths,- useProject,- useQueryProject,- useQueryProjectOrOrganization,-} from "@/src/features/projects/hooks";diff --git a/web/src/features/projects/server/index.ts b/web/src/features/projects/server/index.tsdeleted file mode 100644index 11e9281b06..0000000000--- a/web/src/features/projects/server/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { projectsRouter } from "@/src/features/projects/server/projectsRouter";-export { ProjectService } from "@/src/features/projects/server/projectService";diff --git a/web/src/features/projects/server/projectService.ts b/web/src/features/projects/server/projectService.tsindex 77f99309d8..32a020eecd 100644--- a/web/src/features/projects/server/projectService.ts+++ b/web/src/features/projects/server/projectService.ts@@ -2,13 +2,14 @@ import { randomUUID } from "crypto";import { ForbiddenError, InternalServerError } from "@langfuse/shared";import type { PrismaClient } from "@langfuse/shared/src/db";import { ProjectDeleteQueue, QueueJobs } from "@langfuse/shared/src/server";+import { GatewayConfigService } from "@/src/features/ai-gateway/server/config/gatewayConfigService";+import { invalidateGatewayResolveCacheForOrganization } from "@/src/features/ai-gateway/server/resolve/gatewayResolveCache";import {- GatewayConfigService,- invalidateGatewayResolveCacheForOrganization,-} from "@/src/features/ai-gateway/server";-import { auditLog, type AuditLogActor } from "@/src/features/audit-logs/server";-import type { ApiAuthService } from "@/src/features/public-api/server";-import { emitChbProjectEvent } from "@/src/ee/features/billing/server";+ auditLog,+ type AuditLogActor,+} from "@/src/features/audit-logs/auditLog";+import type { ApiAuthService } from "@/src/features/public-api/server/apiAuth";+import { emitChbProjectEvent } from "@/src/ee/features/billing/server/chb/chbProjectEvents";type DeleteProjectParams = {organizationId: string;diff --git a/web/src/features/projects/server/projectsRouter.ts b/web/src/features/projects/server/projectsRouter.tsindex 024f9a1c80..93c85c3ebf 100644--- a/web/src/features/projects/server/projectsRouter.ts+++ b/web/src/features/projects/server/projectsRouter.ts@@ -1,4 +1,4 @@-import { GatewayConfigService } from "@/src/features/ai-gateway/server";+import { GatewayConfigService } from "@/src/features/ai-gateway/server/config/gatewayConfigService";import { ProjectService } from "@/src/features/projects/server/projectService";import {createTRPCRouter,@@ -9,13 +9,13 @@ import * as z from "zod";import {hasOrganizationAccess,throwIfNoOrganizationAccess,- throwIfNoProjectAccess,-} from "@/src/features/rbac";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";+} from "@/src/features/rbac/utils/checkOrganizationAccess";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";import { TRPCError } from "@trpc/server";import { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";-import { auditLog } from "@/src/features/audit-logs/server";-import { ApiAuthService } from "@/src/features/public-api/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { ApiAuthService } from "@/src/features/public-api/server/apiAuth";import {redis,DefaultEvalModelService,@@ -25,8 +25,8 @@ import {import { transferRoleAssignments } from "@langfuse/shared/rbac/server";import { reconcileTopicsConnectionsForProject } from "@langfuse/shared/topics/server";import { StringNoHTMLNonEmpty } from "@langfuse/shared";-import { buildAdminOrgContext } from "@/src/features/organizations/server";-import { emitChbProjectEvent } from "@/src/ee/features/billing/server";+import { buildAdminOrgContext } from "@/src/features/organizations/server/adminOrgContext";+import { emitChbProjectEvent } from "@/src/ee/features/billing/server/chb/chbProjectEvents";export const projectsRouter = createTRPCRouter({create: protectedOrganizationProcedurediff --git a/web/src/features/prompts/PromptMetricsPage.tsx b/web/src/features/prompts/PromptMetricsPage.tsxindex b9f83cf9ce..6a6dbbf7ed 100644--- a/web/src/features/prompts/PromptMetricsPage.tsx+++ b/web/src/features/prompts/PromptMetricsPage.tsx@@ -6,7 +6,7 @@ import {} from "@/src/components/table/data-table-row-height-switch";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";import { type LangfuseColumnDef } from "@/src/components/table/types";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { useRouter } from "next/router";import { api } from "@/src/utils/api";import { NumberParam, useQueryParams, withDefault } from "use-query-params";@@ -16,22 +16,23 @@ import { createNumberTableColumn } from "@/src/components/design-system/table/coimport { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";import { numberFormatter, usdFormatter } from "@/src/utils/numbers";import { formatIntervalSeconds } from "@/src/utils/dates";-import {- useColumnVisibility,- useColumnOrder,-} from "@/src/features/column-visibility";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";import { Skeleton } from "@/src/components/ui/skeleton";import { type ScoreAggregate } from "@langfuse/shared";import Page from "@/src/components/layouts/Page";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import { toPromptLabelListItems } from "@/src/features/prompts/utils";import { LabelList } from "@/src/components/design-system/LabelList/LabelList";-import { getPromptTabs, PROMPT_TABS } from "@/src/features/navigation";import {- useScoreColumns,+ getPromptTabs,+ PROMPT_TABS,+} from "@/src/features/navigation/utils/prompt-tabs";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";+import {scoreFilters,addPrefixToScoreKeys,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/scoreColumns";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { useTableDateRange } from "@/src/hooks/useTableDateRange";import { toAbsoluteTimeRange } from "@/src/utils/date-range-utils";diff --git a/web/src/features/prompts/PromptsPage.tsx b/web/src/features/prompts/PromptsPage.tsxindex d56b038977..3c93b2a8ec 100644--- a/web/src/features/prompts/PromptsPage.tsx+++ b/web/src/features/prompts/PromptsPage.tsx@@ -2,21 +2,21 @@ import { useRouter } from "next/router";import { ActionButton } from "@/src/components/ActionButton";import Page from "@/src/components/layouts/Page";import { PromptTable } from "@/src/features/prompts/components/PromptTable";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Download, UploadIcon, PlusIcon } from "@langfuse/icons";import { api } from "@/src/utils/api";import { PromptsOnboarding } from "@/src/components/onboarding/PromptsOnboarding";-import { useEntitlementLimit } from "@/src/features/entitlements";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";import { PromptDetail } from "@/src/features/prompts/components/PromptDetail";import PromptMetrics from "@/src/features/prompts/PromptMetricsPage";import { useQueryParams, StringParam } from "use-query-params";import { useState } from "react";-import { AutomationButton } from "@/src/features/automations";+import { AutomationButton } from "@/src/features/automations/components/AutomationButton";import { ImportPromptsButtonDialogController } from "@/src/features/prompts/components/ImportPromptsButtonDialogController";import { Button } from "@/src/components/ui/button";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { showToast } from "@/src/features/notifications";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";export default function PromptsPage() {diff --git a/web/src/features/prompts/components/DeleteFolder.tsx b/web/src/features/prompts/components/DeleteFolder.tsxindex 066bccd840..86fe05ebfd 100644--- a/web/src/features/prompts/components/DeleteFolder.tsx+++ b/web/src/features/prompts/components/DeleteFolder.tsx@@ -1,7 +1,7 @@/* eslint-disable no-nested-ternary, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. *//* eslint-disable @repo/no-abstracted-overlay-trigger */import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { useState } from "react";import {diff --git a/web/src/features/prompts/components/DeletePrompt.tsx b/web/src/features/prompts/components/DeletePrompt.tsxindex 8a369a4bab..4cd7edacc9 100644--- a/web/src/features/prompts/components/DeletePrompt.tsx+++ b/web/src/features/prompts/components/DeletePrompt.tsx@@ -1,6 +1,6 @@/* eslint-disable @repo/no-abstracted-overlay-trigger */import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { Trash } from "@langfuse/icons";import { useState } from "react";diff --git a/web/src/features/prompts/components/DeletePromptVersion.tsx b/web/src/features/prompts/components/DeletePromptVersion.tsxindex 0891ec3055..438fcd1c49 100644--- a/web/src/features/prompts/components/DeletePromptVersion.tsx+++ b/web/src/features/prompts/components/DeletePromptVersion.tsx@@ -1,6 +1,6 @@/* eslint-disable @repo/no-abstracted-overlay-trigger */import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { Trash } from "@langfuse/icons";import { useState } from "react";@@ -11,7 +11,7 @@ import {} from "@/src/components/ui/popover";import { useRouter } from "next/router";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export function DeletePromptVersion({promptVersionId,diff --git a/web/src/features/prompts/components/DuplicateFolderButton.tsx b/web/src/features/prompts/components/DuplicateFolderButton.tsxindex 4db13b3648..5c2132c49e 100644--- a/web/src/features/prompts/components/DuplicateFolderButton.tsx+++ b/web/src/features/prompts/components/DuplicateFolderButton.tsx@@ -1,6 +1,6 @@/* eslint-disable @repo/no-abstracted-overlay-trigger, @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */import { Button } from "@/src/components/ui/button";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { useState } from "react";import {@@ -29,8 +29,8 @@ import { z } from "zod/v4";import { zodResolver } from "@hookform/resolvers/zod";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { Copy } from "@langfuse/icons";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useEntitlementLimit } from "@/src/features/entitlements";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";enum CopySettings {LATEST_ONLY = "latest_only",diff --git a/web/src/features/prompts/components/DuplicatePromptButton.tsx b/web/src/features/prompts/components/DuplicatePromptButton.tsxindex 29bf3cfccf..09c1cd5288 100644--- a/web/src/features/prompts/components/DuplicatePromptButton.tsx+++ b/web/src/features/prompts/components/DuplicatePromptButton.tsx@@ -3,7 +3,7 @@ import { useRouter } from "next/router";import { Button } from "@/src/components/ui/button";import { api, reportNonTrpcError } from "@/src/utils/api";import { Copy } from "@langfuse/icons";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {Dialog,DialogBody,@@ -14,8 +14,8 @@ import {DialogTrigger,} from "@/src/components/ui/dialog";import { ActionButton } from "@/src/components/ActionButton";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useEntitlementLimit } from "@/src/features/entitlements";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";import { useState } from "react";import {Form,diff --git a/web/src/features/prompts/components/ImportPromptsButtonDialogController.tsx b/web/src/features/prompts/components/ImportPromptsButtonDialogController.tsxindex 7434eba7df..039e10c70e 100644--- a/web/src/features/prompts/components/ImportPromptsButtonDialogController.tsx+++ b/web/src/features/prompts/components/ImportPromptsButtonDialogController.tsx@@ -1,5 +1,5 @@/* eslint-disable @typescript-eslint/no-deprecated -- Legacy UI usage retained during migration to design-system components. */-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { type ReactNode, useState } from "react";import { CheckCircle, XCircle, Loader2 } from "@langfuse/icons";import { Dropzone } from "@/src/components/design-system/Dropzone/Dropzone";@@ -13,7 +13,7 @@ import {DialogTitle,} from "@/src/components/ui/dialog";import { api } from "@/src/utils/api";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { CreatePromptSchema } from "@langfuse/shared";import { z } from "zod";diff --git a/web/src/features/prompts/components/NewPromptForm/NewPromptForm.tsx b/web/src/features/prompts/components/NewPromptForm/NewPromptForm.tsxindex eef12e0283..7d8e11aaf1 100644--- a/web/src/features/prompts/components/NewPromptForm/NewPromptForm.tsx+++ b/web/src/features/prompts/components/NewPromptForm/NewPromptForm.tsx@@ -41,8 +41,8 @@ import { SquareArrowOutUpRight } from "@langfuse/icons";import { PromptVariableListPreview } from "@/src/features/prompts/components/PromptVariableListPreview";import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { PromptLinkingEditor } from "@/src/components/editor/PromptLinkingEditor";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { usePlaygroundCache } from "@/src/features/playground";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { default as usePlaygroundCache } from "@/src/features/playground/page/hooks/usePlaygroundCache";import { useQueryParam } from "use-query-params";import { usePromptNameValidation } from "@/src/features/prompts/hooks/usePromptNameValidation";import { getPromptDetailHref } from "@/src/features/prompts/utils";diff --git a/web/src/features/prompts/components/NewPromptForm/PromptChatMessages.tsx b/web/src/features/prompts/components/NewPromptForm/PromptChatMessages.tsxindex e68a37f097..2d5879b8e7 100644--- a/web/src/features/prompts/components/NewPromptForm/PromptChatMessages.tsx+++ b/web/src/features/prompts/components/NewPromptForm/PromptChatMessages.tsx@@ -19,9 +19,9 @@ import { PromptSelectionDialog } from "../PromptSelectionDialog";import {MessageSearchPageProvider,MessageSearchProvider,- MessageSearchToolbar,useSyncMessageSearchMessages,-} from "@/src/components/ChatMessages/MessageSearch";+} from "@/src/components/ChatMessages/messageSearch/context";+import { MessageSearchToolbar } from "@/src/components/ChatMessages/messageSearch/toolbar";import type { ControllerRenderProps } from "react-hook-form";import type { MessagesContext } from "@/src/components/ChatMessages/types";diff --git a/web/src/features/prompts/components/PromptDetail.tsx b/web/src/features/prompts/components/PromptDetail.tsxindex a75b868d6d..941ffb9836 100644--- a/web/src/features/prompts/components/PromptDetail.tsx+++ b/web/src/features/prompts/components/PromptDetail.tsx@@ -8,7 +8,7 @@ import {withDefault,} from "use-query-params";import type { z } from "zod";-import { shouldRenderMessageForContentMode } from "@/src/features/traces";+import { shouldRenderMessageForContentMode } from "@/src/features/traces/fns/chatMessageUtils";import { PromptMessagePreview } from "./PromptMessagePreview/PromptMessagePreview";import { Tabs } from "@/src/components/design-system/Tabs/Tabs";import { BadgeShell } from "@/src/components/design-system/Badge/Badge";@@ -16,7 +16,7 @@ import { IconButton } from "@/src/components/design-system/IconButton/IconButtonimport { DetailViewHeaderShell } from "@/src/features/traces/components/DetailViewHeaderShell";import { JSONView } from "@/src/components/ui/CodeJsonViewer";import { CodeSection } from "@/src/components/design-system/CodeSection/CodeSection";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { api } from "@/src/utils/api";import { getNumberFromMap } from "@/src/utils/map-utils";@@ -25,14 +25,18 @@ import {extractVariables,PRODUCTION_LABEL,PromptType,+ ChatMlArraySchema,} from "@langfuse/shared";-import { getPromptTabs, PROMPT_TABS } from "@/src/features/navigation";+import {+ getPromptTabs,+ PROMPT_TABS,+} from "@/src/features/navigation/utils/prompt-tabs";import { PromptHistoryNode } from "./PromptHistoryNode";-import { JumpToPlaygroundDropdownMenuController } from "@/src/features/playground";-import { ChatMlArraySchema } from "@/src/components/schemas/ChatMlSchema";-import { ObservationsTable as LegacyGenerations } from "@/src/features/tracing-tables";+import { JumpToPlaygroundDropdownMenuController } from "@/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController";++import { default as LegacyGenerations } from "@/src/features/tracing-tables/observations/ObservationsTable";import EventsTable from "@/src/features/events/components/EventsTable";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import {FlaskConical,History,@@ -43,18 +47,18 @@ import {Terminal,} from "@langfuse/icons";import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Button } from "@/src/components/ui/button";import { ActionButtonCountBadge } from "@/src/components/ui/ActionButtonCountBadge";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {Dialog,DialogContent,DialogTrigger,} from "@/src/components/ui/dialog";-import { CreateExperimentsForm } from "@/src/features/experiments";+import { CreateExperimentsForm } from "@/src/features/experiments/components/CreateExperimentsForm";import { useMemo, useState } from "react";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { DuplicatePromptButton } from "@/src/features/prompts/components/DuplicatePromptButton";import Page from "@/src/components/layouts/Page";import {@@ -64,19 +68,19 @@ import {DropdownMenuItem,} from "@/src/components/ui/dropdown-menu";import { DeletePromptVersion } from "@/src/features/prompts/components/DeletePromptVersion";-import { TagPromptDetailsPopover } from "@/src/features/tag";+import { TagPromptDetailsPopover } from "@/src/features/tag/components/TagPromptDetailsPopover";import { SetPromptVersionLabels } from "@/src/features/prompts/components/SetPromptVersionLabels";import {CommentDrawerController,getCommentDrawerInitialStateFromUrl,-} from "@/src/features/comments";+} from "@/src/features/comments/CommentDrawerController";import { Command, CommandInput } from "@/src/components/ui/command";import {PromptReferenceProvider,renderRichPromptContent,} from "@/src/components/ui/PromptReferences";import { PromptVariableListPreview } from "@/src/features/prompts/components/PromptVariableListPreview";-import { createBreadcrumbItems } from "@/src/features/folders";+import { createBreadcrumbItems } from "@/src/features/folders/utils";import { useIsMobile } from "@/src/hooks/use-mobile";import {Drawer,diff --git a/web/src/features/prompts/components/PromptMessagePreview/PromptMessagePreview.stories.tsx b/web/src/features/prompts/components/PromptMessagePreview/PromptMessagePreview.stories.tsxindex da70e3144b..25665254cd 100644--- a/web/src/features/prompts/components/PromptMessagePreview/PromptMessagePreview.stories.tsx+++ b/web/src/features/prompts/components/PromptMessagePreview/PromptMessagePreview.stories.tsx@@ -1,6 +1,6 @@import preview from "../../../../../.storybook/preview";import { expect, spyOn } from "storybook/test";-import { ChatMlMessageSchema } from "@/src/components/schemas/ChatMlSchema";+import { ChatMlMessageSchema } from "@langfuse/shared";import { MarkdownRenderCharacterLimitContext } from "@/src/components/MarkdownRenderCharacterLimitProvider/MarkdownRenderCharacterLimitContext";import { PromptMessagePreview } from "./PromptMessagePreview";diff --git a/web/src/features/prompts/components/PromptTable.tsx b/web/src/features/prompts/components/PromptTable.tsxindex 41d3f61480..b094ea17db 100644--- a/web/src/features/prompts/components/PromptTable.tsx+++ b/web/src/features/prompts/components/PromptTable.tsx@@ -13,42 +13,34 @@ import { SearchableTableFilterLayout } from "@/src/components/table/resizable-fiimport { TextLink } from "@/src/components/design-system/TextLink/TextLink";import { createFolderKeyTableColumn } from "@/src/components/design-system/table/columns/createFolderKeyTableColumn";import { type LangfuseColumnDef } from "@/src/components/table/types";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { DeletePrompt } from "@/src/features/prompts/components/DeletePrompt";import { DeleteFolder } from "@/src/features/prompts/components/DeleteFolder";import { DuplicateFolderButton } from "@/src/features/prompts/components/DuplicateFolderButton";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { api } from "@/src/utils/api";import { type RouterOutput } from "@/src/utils/types";-import { TagPromptPopover } from "@/src/features/tag";+import { TagPromptPopover } from "@/src/features/tag/components/TagPromptPopover";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";-import {- promptFilterConfig,- useQueryFilterState,- useSidebarFilterState,-} from "@/src/features/filters";-import { useOrderByState } from "@/src/features/orderBy";+import { promptFilterConfig } from "@/src/features/filters/config/prompts-config";+import { useQueryFilterState } from "@/src/features/filters/hooks/useFilterState";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { joinTableCoreAndMetrics } from "@/src/components/table/utils/joinTableCoreAndMetrics";import { Skeleton } from "@/src/components/ui/skeleton";-import {- useFullTextSearch,- TableSearchBar,- toObservedOptions,-} from "@/src/features/search-bar";+import { useFullTextSearch } from "@/src/features/search-bar/hooks/useFullTextSearch";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";-import {- useFolderPagination,- buildFullPath,- FolderBreadcrumb,-} from "@/src/features/folders";+import { useFolderPagination } from "@/src/features/folders/hooks/useFolderPagination";+import { buildFullPath } from "@/src/features/folders/utils";+import { FolderBreadcrumb } from "@/src/features/folders/components/FolderBreadcrumb";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";diff --git a/web/src/features/prompts/components/ProtectedLabelsSettings.tsx b/web/src/features/prompts/components/ProtectedLabelsSettings.tsxindex 4ecc0bc55e..b29aaac9a4 100644--- a/web/src/features/prompts/components/ProtectedLabelsSettings.tsx+++ b/web/src/features/prompts/components/ProtectedLabelsSettings.tsx@@ -11,8 +11,8 @@ import {FormMessage,} from "@/src/components/ui/form";import Header from "@/src/components/layouts/header";-import { useHasProjectAccess } from "@/src/features/rbac";-import { useHasEntitlement } from "@/src/features/entitlements";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";import { XIcon, Check } from "@langfuse/icons";diff --git a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsxindex 446ef134fe..fe75658c09 100644--- a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx+++ b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx@@ -15,7 +15,7 @@ import {PopoverContent,PopoverTrigger,} from "@/src/components/ui/popover";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { api, reportNonTrpcError } from "@/src/utils/api";import {@@ -24,7 +24,7 @@ import {type Prompt,} from "@langfuse/shared";import { LabelCommandItem } from "./LabelCommandItem";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {isReservedPromptLabel,toPromptLabelListItems,diff --git a/web/src/features/prompts/constants/promptsSearchRegistry.clienttest.ts b/web/src/features/prompts/constants/promptsSearchRegistry.clienttest.tsindex a0a44f339f..b05265bf96 100644--- a/web/src/features/prompts/constants/promptsSearchRegistry.clienttest.ts+++ b/web/src/features/prompts/constants/promptsSearchRegistry.clienttest.ts@@ -1,6 +1,7 @@import { describe, expect, it } from "vitest";import { PROMPTS_FIELD_REGISTRY } from "./promptsSearchRegistry";-import { planCommit, filterStateToQueryText } from "@/src/features/search-bar";+import { planCommit } from "@/src/features/search-bar/lib/commit";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";describe("prompt search contract", () => {it("round trips the sidebar filters alongside the existing free-text lane", () => {diff --git a/web/src/features/prompts/constants/promptsSearchRegistry.ts b/web/src/features/prompts/constants/promptsSearchRegistry.tsindex 9d279a06a3..bf7d4abce4 100644--- a/web/src/features/prompts/constants/promptsSearchRegistry.ts+++ b/web/src/features/prompts/constants/promptsSearchRegistry.ts@@ -1,5 +1,5 @@-import { promptFilterConfig } from "@/src/features/filters";-import { fieldRegistryFromColumns } from "@/src/features/search-bar";+import { promptFilterConfig } from "@/src/features/filters/config/prompts-config";+import { fieldRegistryFromColumns } from "@/src/features/search-bar/lib/fields";const facetColumns = new Set(promptFilterConfig.facets.map((facet) => facet.column),diff --git a/web/src/features/prompts/index.ts b/web/src/features/prompts/index.tsdeleted file mode 100644index a46e840ffd..0000000000--- a/web/src/features/prompts/index.ts+++ /dev/null@@ -1,4 +0,0 @@-// The prompts feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export { PromptVariableListPreview } from "@/src/features/prompts/components/PromptVariableListPreview";-export { default as ProtectedLabelsSettings } from "@/src/features/prompts/components/ProtectedLabelsSettings";diff --git a/web/src/features/prompts/server/handlers/promptNameHandler.ts b/web/src/features/prompts/server/handlers/promptNameHandler.tsindex c117afd7ab..ccb555a07f 100644--- a/web/src/features/prompts/server/handlers/promptNameHandler.ts+++ b/web/src/features/prompts/server/handlers/promptNameHandler.ts@@ -4,10 +4,8 @@ import {deletePromptForApi,getPromptForApi,} from "@/src/features/prompts/server/prompt-api-service";-import {- withMiddlewares,- createAuthedProjectAPIRoute,-} from "@/src/features/public-api/server";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";+import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import {GetPromptByNameSchema,LangfuseNotFoundError,diff --git a/web/src/features/prompts/server/handlers/promptVersionHandler.ts b/web/src/features/prompts/server/handlers/promptVersionHandler.tsindex 3b832c7f97..53ac5d705f 100644--- a/web/src/features/prompts/server/handlers/promptVersionHandler.ts+++ b/web/src/features/prompts/server/handlers/promptVersionHandler.ts@@ -1,10 +1,8 @@import { z } from "zod";import { LATEST_PROMPT_LABEL } from "@langfuse/shared";-import {- withMiddlewares,- createAuthedProjectAPIRoute,-} from "@/src/features/public-api/server";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";+import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import { updatePromptLabelsForApi } from "@/src/features/prompts/server/prompt-api-service";const UpdatePromptBodySchema = z.object({diff --git a/web/src/features/prompts/server/handlers/promptsHandler.ts b/web/src/features/prompts/server/handlers/promptsHandler.tsindex 67c967a6b7..86e6eff4b2 100644--- a/web/src/features/prompts/server/handlers/promptsHandler.ts+++ b/web/src/features/prompts/server/handlers/promptsHandler.ts@@ -4,10 +4,8 @@ import {createPromptForApi,listPromptsForApi,} from "@/src/features/prompts/server/prompt-api-service";-import {- withMiddlewares,- createAuthedProjectAPIRoute,-} from "@/src/features/public-api/server";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";+import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import { CreatePromptSchema, GetPromptsMetaSchema } from "@langfuse/shared";export const promptsHandler = withMiddlewares({diff --git a/web/src/features/prompts/server/index.ts b/web/src/features/prompts/server/index.tsdeleted file mode 100644index e353bea1fa..0000000000--- a/web/src/features/prompts/server/index.ts+++ /dev/null@@ -1,8 +0,0 @@-// The prompts feature's server surface (RFC rule 9, amended): the-// public-API prompt service MCP tools already imported by file path.-export {- createPromptForApi,- getPromptForApi,- listPromptsForApi,- updatePromptLabelsForApi,-} from "@/src/features/prompts/server/prompt-api-service";diff --git a/web/src/features/prompts/server/prompt-api-service.ts b/web/src/features/prompts/server/prompt-api-service.tsindex c16c31169c..0b5c81cccf 100644--- a/web/src/features/prompts/server/prompt-api-service.ts+++ b/web/src/features/prompts/server/prompt-api-service.ts@@ -10,7 +10,7 @@ import {} from "@langfuse/shared";import type { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { type AuthorizationContext } from "@/src/features/auth/policy/types";import { createPrompt } from "./actions/createPrompt";import { deletePrompt } from "./actions/deletePrompt";diff --git a/web/src/features/prompts/server/routers/promptRouter.ts b/web/src/features/prompts/server/routers/promptRouter.tsindex c94b2a02fe..8675a96eff 100644--- a/web/src/features/prompts/server/routers/promptRouter.ts+++ b/web/src/features/prompts/server/routers/promptRouter.ts@@ -1,11 +1,9 @@/* eslint-disable @typescript-eslint/no-use-before-define */import { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";-import {- hasEntitlementLimit,- throwIfNoEntitlement,-} from "@/src/features/entitlements/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { hasEntitlementLimit } from "@/src/features/entitlements/server/hasEntitlementLimit";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";import {createTRPCRouter,protectedProjectProcedure,@@ -49,7 +47,7 @@ import {getAggregatedScoresForPromptsFromEvents,postgresSearchCondition,} from "@langfuse/shared/src/server";-import { aggregateScores } from "@/src/features/scores/server";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";import { TRPCError } from "@trpc/server";import { promptChangeEventSourcing } from "@/src/features/prompts/server/promptChangeEventSourcing";diff --git a/web/src/features/prompts/server/utils/authorizeProtectedLabelMutation.ts b/web/src/features/prompts/server/utils/authorizeProtectedLabelMutation.tsindex 11ceed0676..5052771fb5 100644--- a/web/src/features/prompts/server/utils/authorizeProtectedLabelMutation.ts+++ b/web/src/features/prompts/server/utils/authorizeProtectedLabelMutation.ts@@ -7,7 +7,7 @@ import {type AuthorizationContext,type Decision,} from "@/src/features/auth/policy/types";-import { shadowAuthorize } from "@/src/features/public-api/server";+import { shadowAuthorize } from "@/src/features/public-api/server/shadowAuth";import { checkHasProtectedLabels } from "./checkHasProtectedLabels";export type ApiKeyProjectContext = {diff --git a/web/src/features/public-api/components/ApiKeyCreateDialogContent.tsx b/web/src/features/public-api/components/ApiKeyCreateDialogContent.tsxindex 010aa641ed..68f95bc111 100644--- a/web/src/features/public-api/components/ApiKeyCreateDialogContent.tsx+++ b/web/src/features/public-api/components/ApiKeyCreateDialogContent.tsx@@ -25,11 +25,9 @@ import {SelectTrigger,} from "@/src/components/ui/select";import { withoutGatewayRole } from "@/src/features/ai-gateway/fns/separateGatewayApiKeys";-import {- ApiKeyExpirationInput,- type ApiKeyExpirationPreset,- resolveApiKeyExpiration,-} from "@/src/features/apiKey";+import { ApiKeyExpirationInput } from "@/src/features/apiKey/components/ApiKeyExpirationInput/ApiKeyExpirationInput";+import type { ApiKeyExpirationPreset } from "@/src/features/apiKey/constants/apiKeyExpirationOptions";+import { resolveApiKeyExpiration } from "@/src/features/apiKey/fns/resolveApiKeyExpiration";import { ApiKeyDetailContent } from "@/src/features/public-api/components/ApiKeyDetailContent";import { rolePermissionCountLabel } from "@/src/features/rbac/components/RolePermissionList";import { RolePermissionPopup } from "@/src/features/rbac/components/RolePermissionPopup";diff --git a/web/src/features/public-api/components/ApiKeyList.tsx b/web/src/features/public-api/components/ApiKeyList.tsxindex f5523260b5..b6e28171bb 100644--- a/web/src/features/public-api/components/ApiKeyList.tsx+++ b/web/src/features/public-api/components/ApiKeyList.tsx@@ -6,10 +6,8 @@ import Header from "@/src/components/layouts/header";import { CreateApiKeyButton } from "@/src/features/public-api/components/CreateApiKeyButton";import { ConnectedApiKeySettingsTable } from "@/src/features/public-api/components/ApiKeySettingsTable/ConnectedApiKeySettingsTable";import { useLangfuseEnvCode } from "@/src/features/public-api/hooks/useLangfuseEnvCode";-import {- useHasOrganizationAccess,- useHasProjectAccess,-} from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";type ApiKeyScope = "project" | "organization";diff --git a/web/src/features/public-api/components/ApiKeySettingsTable/ApiKeySettingsTable.tsx b/web/src/features/public-api/components/ApiKeySettingsTable/ApiKeySettingsTable.tsxindex 66a0feeee2..e07b529498 100644--- a/web/src/features/public-api/components/ApiKeySettingsTable/ApiKeySettingsTable.tsx+++ b/web/src/features/public-api/components/ApiKeySettingsTable/ApiKeySettingsTable.tsx@@ -10,7 +10,7 @@ import {type SettingsTableProps,} from "@/src/components/SettingsTable/SettingsTable";import { type LangfuseColumnDef } from "@/src/components/table/types";-import { isApiKeyExpired } from "@/src/features/apiKey";+import { isApiKeyExpired } from "@/src/features/apiKey/helpers/isApiKeyExpired";import { type RouterOutput } from "@/src/utils/types";const EXCLUDE_GATEWAY_KEYS = "exclude-gateway";diff --git a/web/src/features/public-api/components/ApiKeySettingsTable/ConnectedApiKeySettingsTable.tsx b/web/src/features/public-api/components/ApiKeySettingsTable/ConnectedApiKeySettingsTable.tsxindex 559d402889..20806d2c62 100644--- a/web/src/features/public-api/components/ApiKeySettingsTable/ConnectedApiKeySettingsTable.tsx+++ b/web/src/features/public-api/components/ApiKeySettingsTable/ConnectedApiKeySettingsTable.tsx@@ -7,8 +7,8 @@ import { DialogController } from "@/src/components/design-system/DialogControlleimport { Input } from "@/src/components/design-system/Input/Input";import { SEPARATE_GATEWAY_API_KEYS } from "@/src/features/ai-gateway/fns/separateGatewayApiKeys";import { type AsyncTableData } from "@/src/components/design-system/table/Table";-import { useIsFeatureEnabled } from "@/src/features/feature-flags";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { filterApiKeysByName } from "@/src/features/public-api/components/ApiKeySettingsTable/fns/filterApiKeysByName";import { api, reportNonTrpcError } from "@/src/utils/api";import {diff --git a/web/src/features/public-api/components/CreateApiKeyButton.tsx b/web/src/features/public-api/components/CreateApiKeyButton.tsxindex 88a9236c87..40deed04fb 100644--- a/web/src/features/public-api/components/CreateApiKeyButton.tsx+++ b/web/src/features/public-api/components/CreateApiKeyButton.tsx@@ -4,7 +4,7 @@ import { Dialog, DialogTrigger } from "@/src/components/ui/dialog";import { api, reportNonTrpcError } from "@/src/utils/api";import { useState } from "react";import { PlusIcon } from "@langfuse/icons";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useLangfuseBaseUrl } from "@/src/features/public-api/hooks/useLangfuseEnvCode";import {ApiKeyCreateDialogContent,diff --git a/web/src/features/public-api/components/CreateLLMApiKeyDialog.tsx b/web/src/features/public-api/components/CreateLLMApiKeyDialog.tsxindex 0a751ce11e..d18aee1374 100644--- a/web/src/features/public-api/components/CreateLLMApiKeyDialog.tsx+++ b/web/src/features/public-api/components/CreateLLMApiKeyDialog.tsx@@ -8,9 +8,9 @@ import {DialogTitle,DialogTrigger,} from "@/src/components/ui/dialog";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";-import { useUiCustomization } from "@/src/ee/features/ui-customization";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import { CreateLLMApiKeyForm } from "@/src/features/public-api/components/CreateLLMApiKeyForm";export function CreateLLMApiKeyDialog({diff --git a/web/src/features/public-api/components/CreateLLMApiKeyDialogController.tsx b/web/src/features/public-api/components/CreateLLMApiKeyDialogController.tsxindex 4a295f79b8..dee2f91e20 100644--- a/web/src/features/public-api/components/CreateLLMApiKeyDialogController.tsx+++ b/web/src/features/public-api/components/CreateLLMApiKeyDialogController.tsx@@ -7,15 +7,13 @@ import {DialogHeader,DialogTitle,} from "@/src/components/ui/dialog";-import { useUiCustomization } from "@/src/ee/features/ui-customization";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import {CreateLLMApiKeyForm,type LlmConnectionFormOwner,} from "@/src/features/public-api/components/CreateLLMApiKeyForm";-import {- useHasOrganizationAccess,- useHasProjectAccess,-} from "@/src/features/rbac";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export function CreateLLMApiKeyDialogController({owner,diff --git a/web/src/features/public-api/components/CreateLLMApiKeyForm.clienttest.tsx b/web/src/features/public-api/components/CreateLLMApiKeyForm.clienttest.tsxindex a5fb4a5080..455c1ca65e 100644--- a/web/src/features/public-api/components/CreateLLMApiKeyForm.clienttest.tsx+++ b/web/src/features/public-api/components/CreateLLMApiKeyForm.clienttest.tsx@@ -11,7 +11,7 @@ const mocks = vi.hoisted(() => ({reportTrpcErrorWithoutToast: vi.fn(),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));vi.mock("@/src/utils/api", () => {diff --git a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsxindex f066cbcb4f..cb5d25c66f 100644--- a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx+++ b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx@@ -44,15 +44,16 @@ import {reportTrpcErrorWithoutToast,type RouterOutputs,} from "@/src/utils/api";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { type useUiCustomization } from "@/src/ee/features/ui-customization";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import type { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import { DialogFooter, DialogBody } from "@/src/components/ui/dialog";import { env } from "@/src/env.mjs";import {AuthMethod,BedrockAuthMethodSchema,type BedrockAuthMethod,-} from "@/src/features/llm-api-key";+} from "@/src/features/llm-api-key/types";+const isLangfuseCloud = Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION);/**diff --git a/web/src/features/public-api/components/LLMApiKeySettingsTable/ConnectedLLMApiKeySettingsTable.tsx b/web/src/features/public-api/components/LLMApiKeySettingsTable/ConnectedLLMApiKeySettingsTable.tsxindex 2459f2b280..741be2ae51 100644--- a/web/src/features/public-api/components/LLMApiKeySettingsTable/ConnectedLLMApiKeySettingsTable.tsx+++ b/web/src/features/public-api/components/LLMApiKeySettingsTable/ConnectedLLMApiKeySettingsTable.tsx@@ -5,11 +5,9 @@ import { type AsyncTableData } from "@/src/components/design-system/table/Table"import { CreateLLMApiKeyDialogController } from "@/src/features/public-api/components/CreateLLMApiKeyDialogController";import { UpdateLLMApiKeyDialog } from "@/src/features/public-api/components/UpdateLLMApiKeyDialog";import type { LlmConnectionFormOwner } from "@/src/features/public-api/components/CreateLLMApiKeyForm";-import {- useHasOrganizationAccess,- useHasProjectAccess,-} from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api, reportNonTrpcError } from "@/src/utils/api";import {LLMApiKeySettingsTable,diff --git a/web/src/features/public-api/components/LlmApiKeyList.clienttest.tsx b/web/src/features/public-api/components/LlmApiKeyList.clienttest.tsxindex bbeb9956a8..78ddd32a4b 100644--- a/web/src/features/public-api/components/LlmApiKeyList.clienttest.tsx+++ b/web/src/features/public-api/components/LlmApiKeyList.clienttest.tsx@@ -20,14 +20,18 @@ vi.mock("@/src/components/ui/InfoTooltip/InfoTooltip", () => ({<span aria-label={label}>{children}</span>),}));-vi.mock("@/src/features/rbac", () => ({+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({useHasProjectAccess: () => true,useHasOrganizationAccess: () => true,}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/rbac/utils/checkOrganizationAccess", () => ({+ useHasProjectAccess: () => true,+ useHasOrganizationAccess: () => true,+}));+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));-vi.mock("@/src/ee/features/ui-customization", () => ({+vi.mock("@/src/ee/features/ui-customization/useUiCustomization", () => ({useUiCustomization: () => undefined,}));vi.mock("./CreateLLMApiKeyDialog", () => ({diff --git a/web/src/features/public-api/components/LlmApiKeyList.tsx b/web/src/features/public-api/components/LlmApiKeyList.tsxindex 2681be199c..b226256632 100644--- a/web/src/features/public-api/components/LlmApiKeyList.tsx+++ b/web/src/features/public-api/components/LlmApiKeyList.tsx@@ -1,7 +1,7 @@import { useMemo } from "react";import { Building2, Plug } from "@langfuse/icons";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Alert } from "@/src/components/design-system/Alert/Alert";import { InfoTooltip } from "@/src/components/ui/InfoTooltip/InfoTooltip";import Header from "@/src/components/layouts/header";diff --git a/web/src/features/public-api/components/UpdateLLMApiKeyDialog.tsx b/web/src/features/public-api/components/UpdateLLMApiKeyDialog.tsxindex b02b92a484..1e01f26dd3 100644--- a/web/src/features/public-api/components/UpdateLLMApiKeyDialog.tsx+++ b/web/src/features/public-api/components/UpdateLLMApiKeyDialog.tsx@@ -11,7 +11,7 @@ import {type LlmApiKeyListItem,type LlmConnectionFormOwner,} from "./CreateLLMApiKeyForm";-import { useUiCustomization } from "@/src/ee/features/ui-customization";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";export function UpdateLLMApiKeyDialog({owner,diff --git a/web/src/features/public-api/hooks/useLangfuseEnvCode.ts b/web/src/features/public-api/hooks/useLangfuseEnvCode.tsindex f2410c7860..edce86b69c 100644--- a/web/src/features/public-api/hooks/useLangfuseEnvCode.ts+++ b/web/src/features/public-api/hooks/useLangfuseEnvCode.ts@@ -1,4 +1,4 @@-import { useUiCustomization } from "@/src/ee/features/ui-customization";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import { env } from "@/src/env.mjs";type LangfuseKeys = {diff --git a/web/src/features/public-api/index.ts b/web/src/features/public-api/index.tsdeleted file mode 100644index 91364b8de3..0000000000--- a/web/src/features/public-api/index.ts+++ /dev/null@@ -1,18 +0,0 @@-export {- DeleteEvaluatorResponse,- Evaluator,- ListEvaluatorVersionsResponse,- ListEvaluatorsResponse,- LlmAsJudgeEvaluator,-} from "./types/evaluation/evaluators";-export {- DeleteEvaluationRuleResponse,- EvaluationRule,- ListEvaluationRulesResponse,-} from "./types/evaluation/evaluationRules";-export { PublicApiError } from "./types/public-api-errors";-export {- createStructuredPublicApiError,- StructuredPublicApiError,-} from "./types/structuredPublicApiError";-export { LlmConnectionEmptyState } from "./components/LlmConnectionEmptyState/LlmConnectionEmptyState";diff --git a/web/src/features/public-api/server/apiAuth.ts b/web/src/features/public-api/server/apiAuth.tsindex 157929f62c..58b0f534dc 100644--- a/web/src/features/public-api/server/apiAuth.ts+++ b/web/src/features/public-api/server/apiAuth.ts@@ -25,7 +25,7 @@ import {} from "@langfuse/shared/src/db";import { isPrismaException } from "@/src/utils/exceptions";import { type Redis, type Cluster } from "ioredis";-import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server";+import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import { type z } from "zod";import { CloudConfigSchema, isPlan, UnauthorizedError } from "@langfuse/shared";import { isApiKeyExpired } from "@/src/features/apiKey/helpers/isApiKeyExpired";diff --git a/web/src/features/public-api/server/authenticateOrganizationApiRequest.ts b/web/src/features/public-api/server/authenticateOrganizationApiRequest.tsindex 812ebe8b8b..052cb95e50 100644--- a/web/src/features/public-api/server/authenticateOrganizationApiRequest.ts+++ b/web/src/features/public-api/server/authenticateOrganizationApiRequest.ts@@ -1,7 +1,7 @@import type { NextApiRequest, NextApiResponse } from "next";import type { Action } from "@langfuse/shared/rbac";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import { RateLimitService } from "./RateLimitService";import { shadowAuth } from "./shadowAuth";import { writeOrgError } from "./writeError";diff --git a/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts b/web/src/features/public-api/server/createAuthedProjectAPIRoute.tsindex eb576286f9..6716eb5197 100644--- a/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts+++ b/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts@@ -17,7 +17,7 @@ import {type RateLimitResource,type ApiDeprecationInfo,} from "@langfuse/shared";-import { verifyGatewayIngestionAuthorization } from "@/src/features/ai-gateway/server";+import { verifyGatewayIngestionAuthorization } from "@/src/features/ai-gateway/server/auth/ingestionTokenVerifier";import { RateLimitService } from "@/src/features/public-api/server/RateLimitService";import { type RateLimitUpgradePath } from "@/src/features/public-api/server/rateLimitUpgradePaths";import * as opentelemetry from "@opentelemetry/api";diff --git a/web/src/features/public-api/server/dataset-runs.ts b/web/src/features/public-api/server/dataset-runs.tsdeleted file mode 100644index 927ceaa3dd..0000000000--- a/web/src/features/public-api/server/dataset-runs.ts+++ /dev/null@@ -1 +0,0 @@-export { createOrFetchDatasetRun } from "@langfuse/shared/src/server";diff --git a/web/src/features/public-api/server/enforceAuth.ts b/web/src/features/public-api/server/enforceAuth.tsindex b8cc9130bd..97e2e2478a 100644--- a/web/src/features/public-api/server/enforceAuth.ts+++ b/web/src/features/public-api/server/enforceAuth.ts@@ -25,7 +25,7 @@ import {} from "@langfuse/shared/rbac";import { authorize } from "@/src/features/rbac/authorize";-import { authenticator } from "@/src/features/apiKey/server";+import { authenticator } from "@/src/features/apiKey/authenticator";import { toApiAccessScope } from "@/src/features/public-api/server/toApiAccessScope";import {forbiddenError,diff --git a/web/src/features/public-api/server/evaluation/evaluationAdapters.ts b/web/src/features/public-api/server/evaluation/evaluationAdapters.tsindex b76007e83d..f5244c7b8b 100644--- a/web/src/features/public-api/server/evaluation/evaluationAdapters.ts+++ b/web/src/features/public-api/server/evaluation/evaluationAdapters.ts@@ -12,12 +12,10 @@ import {type ObservationVariableMapping,} from "@langfuse/shared";import { logger } from "@langfuse/shared/src/server";-import {- EvaluatorDefinitionInputSchema,- isLegacyEvalTarget,- type EvaluatorService,- type RuleService,-} from "@/src/features/evals/server";+import { EvaluatorDefinitionInputSchema } from "@/src/features/evals/v2/server/evaluators/evaluatorTypes";+import { isLegacyEvalTarget } from "@/src/features/evals/utils/typeHelpers";+import type { EvaluatorService } from "@/src/features/evals/v2/server/evaluators/evaluatorService";+import type { RuleService } from "@/src/features/evals/v2/server/rules/ruleService";import {EvaluationRule,type CreateEvaluationRuleBodyType,diff --git a/web/src/features/public-api/server/evaluation/evaluationRuleApiService.ts b/web/src/features/public-api/server/evaluation/evaluationRuleApiService.tsindex 8ca5ae0043..7e078e00cd 100644--- a/web/src/features/public-api/server/evaluation/evaluationRuleApiService.ts+++ b/web/src/features/public-api/server/evaluation/evaluationRuleApiService.ts@@ -1,11 +1,9 @@import { EvalTargetObject } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";import type { ApiAccessScope } from "@langfuse/shared/src/server";-import { auditLog } from "@/src/features/audit-logs/server";-import {- JOB_CONFIGURATION_AUDIT_LOG_RESOURCE_TYPE,- RuleService,-} from "@/src/features/evals/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { JOB_CONFIGURATION_AUDIT_LOG_RESOURCE_TYPE } from "@/src/features/evals/server/audit-log-resource-types";+import { RuleService } from "@/src/features/evals/v2/server/rules/ruleService";import {type CreateEvaluationRuleBodyType,type UpdateEvaluationRuleBodyType,diff --git a/web/src/features/public-api/server/evaluation/evaluatorApiService.ts b/web/src/features/public-api/server/evaluation/evaluatorApiService.tsindex 995846dfcf..dd290b20b7 100644--- a/web/src/features/public-api/server/evaluation/evaluatorApiService.ts+++ b/web/src/features/public-api/server/evaluation/evaluatorApiService.ts@@ -5,11 +5,9 @@ import {} from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";import type { ApiAccessScope } from "@langfuse/shared/src/server";-import { auditLog } from "@/src/features/audit-logs/server";-import {- EVAL_TEMPLATE_AUDIT_LOG_RESOURCE_TYPE,- EvaluatorService,-} from "@/src/features/evals/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { EVAL_TEMPLATE_AUDIT_LOG_RESOURCE_TYPE } from "@/src/features/evals/server/audit-log-resource-types";+import { EvaluatorService } from "@/src/features/evals/v2/server/evaluators/evaluatorService";import {encodeResourceCursor,type CreateEvaluatorBodyType,diff --git a/web/src/features/public-api/server/health-service.ts b/web/src/features/public-api/server/health-service.tsindex 81254a2878..f3b4fad84f 100644--- a/web/src/features/public-api/server/health-service.ts+++ b/web/src/features/public-api/server/health-service.ts@@ -1,4 +1,4 @@-import { VERSION } from "@/src/constants";+import { VERSION } from "@/src/constants/VERSION";import { env } from "@/src/env.mjs";import { prisma } from "@langfuse/shared/src/db";import {diff --git a/web/src/features/public-api/server/index.ts b/web/src/features/public-api/server/index.tsdeleted file mode 100644index 6180f66c09..0000000000--- a/web/src/features/public-api/server/index.ts+++ /dev/null@@ -1,183 +0,0 @@-export { ApiAuthService } from "./apiAuth";-export { authenticateOrganizationApiRequest } from "./authenticateOrganizationApiRequest";-export { createAuthedProjectAPIRoute } from "./createAuthedProjectAPIRoute";-export { createOrFetchDatasetRun } from "./dataset-runs";-export {- generateDatasetRunItemsForPublicApi,- getDatasetRunItemsCountForPublicApi,-} from "./dataset-run-items";-export { evaluationRuleApiHandler } from "./evaluation/evaluationRuleApiHandler";-export { evaluationRulesApiHandler } from "./evaluation/evaluationRulesApiHandler";-export { evaluatorApiHandler } from "./evaluation/evaluatorApiHandler";-export { evaluatorsApiHandler } from "./evaluation/evaluatorsApiHandler";-export { evaluatorVersionsApiHandler } from "./evaluation/evaluatorVersionsApiHandler";-export { runHealthCheck } from "./health-service";-export { RateLimitService } from "./RateLimitService";-export {- createScoreConfig,- getScoreConfig,- listScoreConfigs,- updateScoreConfig,-} from "./score-configs-api-service";-export { ScoresApiService } from "./scores-api-service";-export { listScoresV3ForPublicApi } from "./scores-api-v3";-export {- createStructuredPublicApiRateLimitError,- structuredPublicApiErrorContract,- toStructuredPublicApiError,-} from "./structuredPublicApiErrorContract";-export { withMiddlewares } from "./withMiddlewares";-export type {- AnnotationQueue,- AnnotationQueueItem,-} from "../types/annotation-queues";-export {- AnnotationQueueAssignmentQuery,- CreateAnnotationQueueAssignmentBody,- CreateAnnotationQueueAssignmentResponse,- CreateAnnotationQueueBody,- CreateAnnotationQueueItemBody,- CreateAnnotationQueueItemResponse,- CreateAnnotationQueueResponse,- DeleteAnnotationQueueAssignmentBody,- DeleteAnnotationQueueAssignmentResponse,- DeleteAnnotationQueueItemQuery,- DeleteAnnotationQueueItemResponse,- GetAnnotationQueueByIdQuery,- GetAnnotationQueueByIdResponse,- GetAnnotationQueueItemByIdQuery,- GetAnnotationQueueItemByIdResponse,- GetAnnotationQueueItemsQuery,- GetAnnotationQueueItemsResponse,- GetAnnotationQueuesQuery,- GetAnnotationQueuesResponse,- UpdateAnnotationQueueItemBody,- UpdateAnnotationQueueItemResponse,-} from "../types/annotation-queues";-export {- GetCommentsV1Query,- GetCommentsV1Response,- GetCommentV1Query,- GetCommentV1Response,- PostCommentsV1Body,- PostCommentsV1Response,-} from "../types/comments";-export type {- APIDatasetItemMediaReference,- APIDatasetRunItem,-} from "../types/datasets";-export {- DeleteDatasetItemV1Query,- DeleteDatasetItemV1Response,- DeleteDatasetRunV1Response,- GetDatasetItemsV1Query,- GetDatasetItemsV1Response,- GetDatasetItemV1Query,- GetDatasetItemV1Response,- GetDatasetRunItemsV1Response,- GetDatasetRunsV1Query,- GetDatasetRunsV1Response,- GetDatasetRunV1Query,- GetDatasetRunV1Response,- GetDatasetsV1Query,- GetDatasetsV2Query,- GetDatasetsV2Response,- GetDatasetV1Query,- GetDatasetV2Response,- PostDatasetItemsV1Body,- PostDatasetItemsV1Response,- PostDatasetRunItemsV1Body,- PostDatasetRunItemsV1Response,- PostDatasetsV1Body,- PostDatasetsV2Body,- PostDatasetsV2Response,- publicApiIdSchema,- transformDbDatasetItemDomainToAPIDatasetItem,- transformDbDatasetRunToAPIDatasetRun,- transformDbDatasetToAPIDataset,-} from "../types/datasets";-export type {- GetExperimentItemsV1QueryType,- GetExperimentsV1QueryType,-} from "../types/experiments";-export {- EncodedExperimentsCursorString,- encodeExperimentCursor,- EXPERIMENT_FILTER_COLUMNS,- EXPERIMENT_ITEM_FILTER_COLUMNS,- GetExperimentItemsV1ParsedQuery,- GetExperimentItemsV1ParsedQueryBase,- GetExperimentItemsV1Response,- GetExperimentsV1ParsedQuery,- GetExperimentsV1Response,-} from "../types/experiments";-export type {- PostFeedbackBodyType,- PostFeedbackResponseType,-} from "../types/feedback";-export { PostFeedbackBody } from "../types/feedback";-export { MetricsQueryObjectV2, publicGranularities } from "../types/metrics";-export {- DeleteModelV1Query,- DeleteModelV1Response,- GetModelsV1Query,- GetModelsV1Response,- GetModelV1Query,- GetModelV1Response,- PostModelsV1Body,- PostModelsV1Response,- prismaToApiModelDefinition,-} from "../types/models";-export {- encodeCursor,- EncodedObservationsCursorV2,- EncodedObservationsCursorV2String,-} from "../types/observations";-export {- GetScoreConfigQuery,- GetScoreConfigsQuery,- PostScoreConfigBody,- PutScoreConfigBodyWithoutArchived,- PutScoreConfigQuery,-} from "../types/score-configs";-export { EncodedScoresCursorV3 } from "../types/scores";-export type {- DashboardWidgetViewOutputType,- PostUnstableDashboardWidgetBodyType,-} from "../types/unstable-dashboard-widgets";-export {- DashboardWidgetIdQuery,- GetUnstableDashboardWidgetsQuery,- PatchUnstableDashboardWidgetBody,- PostUnstableDashboardWidgetBody,- PostUnstableDashboardWidgetResponse,- PostUnstableDashboardWidgetView,-} from "../types/unstable-dashboard-widgets";-export {- DashboardIdQuery,- DashboardPlacementSchema,- DashboardSchema,- GetUnstableDashboardsQuery,- PatchDashboardPlacementBody,- PatchUnstableDashboardBody,- PostDashboardPlacementBody,- PostUnstableDashboardBody,-} from "../types/unstable-dashboards";-export { __dangerouslySkipAuthz, type ApiAction } from "./enforceAuth";-export {- isPublicApiEvaluatorType,- toApiReadMappings,- toPublicEvaluatorType,- toStoredMappingList,-} from "./evaluation/evaluationAdapters";-export {- shadowAuth,- shadowAuthorize,- type ShadowAuthParams,-} from "./shadowAuth";-export { writeOrgError, writeProjectError, writeScimError } from "./writeError";-export {- ObservationPromptVariableMappingInput,- PromptVariableMappingRead,- PublicEvaluatorType,-} from "../types/evaluation/publicEvalsContract";diff --git a/web/src/features/public-api/server/organizationApiKeyRouter.ts b/web/src/features/public-api/server/organizationApiKeyRouter.tsindex b6ff75b2cb..2c96cb6103 100644--- a/web/src/features/public-api/server/organizationApiKeyRouter.ts+++ b/web/src/features/public-api/server/organizationApiKeyRouter.ts@@ -1,6 +1,6 @@-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoOrganizationAccess } from "@/src/features/rbac";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";import {createTRPCRouter,protectedOrganizationProcedure,@@ -14,7 +14,7 @@ import { createApiKey } from "@langfuse/shared/src/server/auth/apiKeys";import { OrganizationId, SystemRoleId, UserId } from "@langfuse/shared/rbac";import { apiKeyCreationRoleSchema } from "@/src/features/public-api/server/apiKeyCreationRoleSchema";import { excludeGatewayApiKeys } from "@/src/features/ai-gateway/server/apiKey/excludeGatewayApiKeys";-import { invalidateGatewayResolveCacheForApiKey } from "@/src/features/ai-gateway/server";+import { invalidateGatewayResolveCacheForApiKey } from "@/src/features/ai-gateway/server/resolve/gatewayResolveCache";import { GATEWAY_ROLE } from "@/src/features/ai-gateway/fns/separateGatewayApiKeys";// Gateway traffic from keys without a bound user reports the key name as its user ID.diff --git a/web/src/features/public-api/server/projectApiKeyRouter.ts b/web/src/features/public-api/server/projectApiKeyRouter.tsindex 3875c7815c..046ffae77f 100644--- a/web/src/features/public-api/server/projectApiKeyRouter.ts+++ b/web/src/features/public-api/server/projectApiKeyRouter.ts@@ -1,5 +1,5 @@-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/features/public-api/server/score-configs-api-service.ts b/web/src/features/public-api/server/score-configs-api-service.tsindex 72013b2ecd..2cea6dbcbd 100644--- a/web/src/features/public-api/server/score-configs-api-service.ts+++ b/web/src/features/public-api/server/score-configs-api-service.ts@@ -1,6 +1,6 @@import { v4 } from "uuid";import { type z } from "zod";-import { isBooleanDataType } from "@/src/features/scores/server";+import { isBooleanDataType } from "@/src/features/scores/lib/helpers";import {InvalidRequestError,LangfuseNotFoundError,@@ -8,7 +8,7 @@ import {validateDbScoreConfigSafe,} from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {type PostScoreConfigBody,type PutScoreConfigBody,diff --git a/web/src/features/public-api/server/scores-api-service.ts b/web/src/features/public-api/server/scores-api-service.tsindex fbdfd1a449..841c34264e 100644--- a/web/src/features/public-api/server/scores-api-service.ts+++ b/web/src/features/public-api/server/scores-api-service.ts@@ -6,7 +6,7 @@ import {convertScoreToPublicApi,type ScoreQueryType,} from "@/src/features/public-api/server/scores";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {InternalServerError,LISTABLE_SCORE_TYPES,diff --git a/web/src/features/public-api/server/scores-api-v3.ts b/web/src/features/public-api/server/scores-api-v3.tsdeleted file mode 100644index 32acd87d9f..0000000000--- a/web/src/features/public-api/server/scores-api-v3.ts+++ /dev/null@@ -1,4 +0,0 @@-export {- listScoresV3ForPublicApi,- polymorphicValueForV3 as polymorphicValue,-} from "@langfuse/shared/src/server";diff --git a/web/src/features/public-api/types/blob-storage-integrations.ts b/web/src/features/public-api/types/blob-storage-integrations.tsindex 3d2c57e579..fe88798574 100644--- a/web/src/features/public-api/types/blob-storage-integrations.ts+++ b/web/src/features/public-api/types/blob-storage-integrations.ts@@ -11,7 +11,7 @@ import {validateExportFieldGroups,exportStartDateNotInFuture,EXPORT_START_DATE_FUTURE_ERROR,-} from "@/src/features/blobstorage-integration";+} from "@/src/features/blobstorage-integration/validation";/*** Enums*/diff --git a/web/src/features/public-api/types/scores.ts b/web/src/features/public-api/types/scores.tsdeleted file mode 100644index dc97375add..0000000000--- a/web/src/features/public-api/types/scores.ts+++ /dev/null@@ -1,4 +0,0 @@-export {- EncodedScoresCursorV3,- encodeCursorV3,-} from "@langfuse/shared/src/server";diff --git a/web/src/features/rbac/components/CreateProjectMemberDialogController.tsx b/web/src/features/rbac/components/CreateProjectMemberDialogController.tsxindex e5ef618797..4550dedf5f 100644--- a/web/src/features/rbac/components/CreateProjectMemberDialogController.tsx+++ b/web/src/features/rbac/components/CreateProjectMemberDialogController.tsx@@ -5,9 +5,9 @@ import { CreateProjectMemberDialog } from "@/src/features/rbac/components/Createimport {useEntitlementLimit,useHasEntitlement,-} from "@/src/features/entitlements";-import { useIsFeatureEnabled } from "@/src/features/feature-flags";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+} from "@/src/features/entitlements/hooks";+import { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";diff --git a/web/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable.tsx b/web/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable.tsxindex bb41f4d2c1..d3cba7aa10 100644--- a/web/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable.tsx+++ b/web/src/features/rbac/components/MembersSettingsTable/ConnectedMembersSettingsTable.tsx@@ -13,9 +13,9 @@ import { Alert } from "@/src/components/design-system/Alert/Alert";import { type AsyncTableData } from "@/src/components/design-system/table/Table";import useSessionStorage from "@/src/components/useSessionStorage";import { env } from "@/src/env.mjs";-import { useHasEntitlement } from "@/src/features/entitlements";-import { useIsFeatureEnabled } from "@/src/features/feature-flags";-import { showSuccessToast } from "@/src/features/notifications";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { CreateProjectMemberDialogController } from "@/src/features/rbac/components/CreateProjectMemberDialogController";import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";diff --git a/web/src/features/rbac/components/MembersSettingsTable/MembersSettingsTable.tsx b/web/src/features/rbac/components/MembersSettingsTable/MembersSettingsTable.tsxindex 6d20cabe0d..4801000637 100644--- a/web/src/features/rbac/components/MembersSettingsTable/MembersSettingsTable.tsx+++ b/web/src/features/rbac/components/MembersSettingsTable/MembersSettingsTable.tsx@@ -17,7 +17,7 @@ import { createUserTableColumn } from "@/src/components/design-system/table/coluimport { type LangfuseColumnDef } from "@/src/components/table/types";import { RoleSelect } from "@/src/features/rbac/components/RoleSelect";import { orderedRoles } from "@/src/features/rbac/constants/orderedRoles";-import type { FeaturePreviewFlag } from "@/src/features/feature-flags";+import type { FeaturePreviewFlag } from "@/src/features/feature-flags/available-flags";import { UserFeaturePreviewsControl } from "@/src/features/feature-flags/components/UserFeaturePreviewsControl";import type { RouterOutput } from "@/src/utils/types";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";diff --git a/web/src/features/rbac/index.ts b/web/src/features/rbac/index.tsdeleted file mode 100644index 610e9fc7fd..0000000000--- a/web/src/features/rbac/index.ts+++ /dev/null@@ -1,33 +0,0 @@-// The rbac feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-//-// Access helpers live in utils/ and mix a React hook with TRPC throws-// in the same file. Re-exporting them here does not change the bundle-// versus today's deep import of those files.-//-// `server/` is deliberately absent: membersRouter stays a direct import-// from the tRPC root, which is not a feature.-//-// Members and invites tables stay off this door. onboardingService and-// other server modules already import the access helpers from here, and-// putting those tables on the barrel pulled CreateProjectMemberDialog-// (react-hook-form) into instrumentation and API routes.-//-// The role catalog (definitions, policies, tags, and access-right tables)-// lives in `@langfuse/shared/rbac`; only policy resolution stays here.-export {- hasProjectAccess,- throwIfNoProjectAccess,- useHasProjectAccess,-} from "@/src/features/rbac/utils/checkProjectAccess";--export {- hasOrganizationAccess,- throwIfNoOrganizationAccess,- useHasOrganizationAccess,-} from "@/src/features/rbac/utils/checkOrganizationAccess";--export {- organizationRoleAccessRights,- type OrganizationScope,-} from "@langfuse/shared/rbac";diff --git a/web/src/features/rbac/server/allMembersRoutes.ts b/web/src/features/rbac/server/allMembersRoutes.tsindex 9cad89fe73..1b943c2170 100644--- a/web/src/features/rbac/server/allMembersRoutes.ts+++ b/web/src/features/rbac/server/allMembersRoutes.ts@@ -25,7 +25,7 @@ import {EMPTY_ORGANIZATION_FEATURE_PREVIEW_STATES,getOrganizationFeaturePreviewStatesByUserId,getUserFeaturePreviewManagementCapabilities,-} from "@/src/features/feature-flags/server";+} from "@/src/features/feature-flags/server/organizationFeatureFlags";const orgLevelMemberQuery = z.object({orgId: z.string(),diff --git a/web/src/features/rbac/server/index.ts b/web/src/features/rbac/server/index.tsdeleted file mode 100644index 61a6903ddb..0000000000--- a/web/src/features/rbac/server/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { inviteOrganizationMember } from "./inviteOrganizationMember";-export { OrganizationMembersService } from "./organizationMembersService";diff --git a/web/src/features/rbac/server/inviteOrganizationMember.ts b/web/src/features/rbac/server/inviteOrganizationMember.tsindex 839d12f7b4..a9eee8d3ce 100644--- a/web/src/features/rbac/server/inviteOrganizationMember.ts+++ b/web/src/features/rbac/server/inviteOrganizationMember.ts@@ -1,15 +1,13 @@import { TRPCError } from "@trpc/server";import { Prisma, type PrismaClient, Role } from "@langfuse/shared";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {getSfdcService,type SetUserRoleInput,-} from "@/src/ee/features/sfdc-sync/server";-import {- createWithinEntitlementLimit,- hasEntitlement,-} from "@/src/features/entitlements/server";+} from "@/src/ee/features/sfdc-sync/server/sfdcService";+import { createWithinEntitlementLimit } from "@/src/features/entitlements/server/createWithinEntitlementLimit";+import { hasEntitlement } from "@/src/features/entitlements/server/hasEntitlement";import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { throwIfHigherProjectRole } from "@/src/features/rbac/server/throwIfHigherProjectRole";diff --git a/web/src/features/rbac/server/membersRouter.ts b/web/src/features/rbac/server/membersRouter.tsindex ae903cf786..c2aa8585dc 100644--- a/web/src/features/rbac/server/membersRouter.ts+++ b/web/src/features/rbac/server/membersRouter.ts@@ -1,4 +1,4 @@-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {createTRPCRouter,protectedOrganizationProcedure,@@ -23,8 +23,8 @@ import {escapeSqlLikePattern,} from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";-import { getSfdcService } from "@/src/ee/features/sfdc-sync/server";-import { hasEntitlement } from "@/src/features/entitlements/server";+import { getSfdcService } from "@/src/ee/features/sfdc-sync/server/sfdcService";+import { hasEntitlement } from "@/src/features/entitlements/server/hasEntitlement";import {hasProjectAccess,throwIfNoProjectAccess,@@ -40,10 +40,8 @@ import {import { inviteOrganizationMember } from "@/src/features/rbac/server/inviteOrganizationMember";import { throwIfHigherProjectRole } from "@/src/features/rbac/server/throwIfHigherProjectRole";import { throwIfHigherRole } from "@/src/features/rbac/server/throwIfHigherRole";-import {- userFeaturePreviewFlags,- setUserFeaturePreviewWithAuthorization,-} from "@/src/features/feature-flags/server";+import { userFeaturePreviewFlags } from "@/src/features/feature-flags/available-flags";+import { setUserFeaturePreviewWithAuthorization } from "@/src/features/feature-flags/server/organizationFeatureFlags";function buildUserSearchFilter(searchQuery: string | undefined | null) {if (searchQuery === undefined || searchQuery === null || searchQuery === "") {diff --git a/web/src/features/score-analytics/index.ts b/web/src/features/score-analytics/index.tsdeleted file mode 100644index 7beadfd0c0..0000000000--- a/web/src/features/score-analytics/index.ts+++ /dev/null@@ -1,10 +0,0 @@-// The score-analytics feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export type { ScoreOption } from "@/src/features/score-analytics/components/charts/ScoreCombobox";-export { ScoreAnalyticsDashboard } from "@/src/features/score-analytics/components/ScoreAnalyticsDashboard";-export { ScoreAnalyticsHeader } from "@/src/features/score-analytics/components/ScoreAnalyticsHeader";-export {- ScoreAnalyticsProvider,- type DataType,-} from "@/src/features/score-analytics/components/ScoreAnalyticsProvider";-export { useAnalyticsUrlState } from "@/src/features/score-analytics/lib/analytics-url-state";diff --git a/web/src/features/score-configs/ScoreConfigsTable/ConnectedScoreConfigsTable.tsx b/web/src/features/score-configs/ScoreConfigsTable/ConnectedScoreConfigsTable.tsxindex 4dae29b1ae..c0aab7e76d 100644--- a/web/src/features/score-configs/ScoreConfigsTable/ConnectedScoreConfigsTable.tsx+++ b/web/src/features/score-configs/ScoreConfigsTable/ConnectedScoreConfigsTable.tsx@@ -10,7 +10,7 @@ import {ScoreConfigsTable,type ScoreConfigTableRow,} from "@/src/features/score-configs/ScoreConfigsTable/ScoreConfigsTable";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { usePaginationState } from "@/src/hooks/usePaginationState";import { api } from "@/src/utils/api";diff --git a/web/src/features/score-configs/ScoreConfigsTable/ScoreConfigsTable.tsx b/web/src/features/score-configs/ScoreConfigsTable/ScoreConfigsTable.tsxindex 7bbedd97de..0623294a2f 100644--- a/web/src/features/score-configs/ScoreConfigsTable/ScoreConfigsTable.tsx+++ b/web/src/features/score-configs/ScoreConfigsTable/ScoreConfigsTable.tsx@@ -26,7 +26,7 @@ import {isBooleanDataType,isCategoricalDataType,isNumericDataType,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/helpers";export type ScoreConfigTableRow = {id: string;diff --git a/web/src/features/score-configs/components/ArchiveScoreConfigDialogController.tsx b/web/src/features/score-configs/components/ArchiveScoreConfigDialogController.tsxindex c1b7a3650e..ad94e77ccb 100644--- a/web/src/features/score-configs/components/ArchiveScoreConfigDialogController.tsx+++ b/web/src/features/score-configs/components/ArchiveScoreConfigDialogController.tsx@@ -2,9 +2,9 @@ import type * as React from "react";import { useState } from "react";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useHasProjectAccess } from "@/src/features/rbac";-import { useEmptyScoreConfigs } from "@/src/features/scores";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { useEmptyScoreConfigs } from "@/src/features/scores/hooks/useEmptyConfigs";import { api } from "@/src/utils/api";export type ArchiveScoreConfigState = {diff --git a/web/src/features/score-configs/components/UpsertScoreConfigDialogContent.tsx b/web/src/features/score-configs/components/UpsertScoreConfigDialogContent.tsxindex ad68743061..d750ff19d4 100644--- a/web/src/features/score-configs/components/UpsertScoreConfigDialogContent.tsx+++ b/web/src/features/score-configs/components/UpsertScoreConfigDialogContent.tsx@@ -24,7 +24,7 @@ import {isCategoricalDataType,isNumericDataType,isTextDataType,-} from "@/src/features/scores";+} from "@/src/features/scores/lib/helpers";import {createConfigSchema,type CreateConfig,diff --git a/web/src/features/score-configs/components/UpsertScoreConfigDialogController.tsx b/web/src/features/score-configs/components/UpsertScoreConfigDialogController.tsxindex 81b0cd378e..89cc14f91f 100644--- a/web/src/features/score-configs/components/UpsertScoreConfigDialogController.tsx+++ b/web/src/features/score-configs/components/UpsertScoreConfigDialogController.tsx@@ -3,8 +3,8 @@ import { ScoreDataTypeEnum } from "@langfuse/shared";import { type ReactNode } from "react";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useHasProjectAccess } from "@/src/features/rbac";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { UpsertScoreConfigDialogContent } from "@/src/features/score-configs/components/UpsertScoreConfigDialogContent";import {type CreateConfig,diff --git a/web/src/features/score-configs/index.ts b/web/src/features/score-configs/index.tsdeleted file mode 100644index bbfe67c86d..0000000000--- a/web/src/features/score-configs/index.ts+++ /dev/null@@ -1,5 +0,0 @@-export { ScoreConfigSettings } from "@/src/features/score-configs/components/ScoreConfigSettings";-export {- CreateScoreConfigDialogController,- EditScoreConfigDialogController,-} from "@/src/features/score-configs/components/UpsertScoreConfigDialogController";diff --git a/web/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel.stories.tsx b/web/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel.stories.tsxindex b259cad65c..f206684c37 100644--- a/web/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel.stories.tsx+++ b/web/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel.stories.tsx@@ -1,6 +1,6 @@import preview from "../../../../../.storybook/preview";import { fn } from "storybook/test";-import type { DataPoint } from "@/src/features/widgets";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";import { DEFAULT_SCORE_CHART_CONFIG } from "@/src/features/scores-chart-view/constants/defaultScoreChartConfig";import { type ScoreChartViewConfig } from "@/src/features/scores-chart-view/types";import { ScoreChartViewPanel } from "@/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel";diff --git a/web/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel.tsx b/web/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel.tsxindex ff4c787675..21795a4515 100644--- a/web/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel.tsx+++ b/web/src/features/scores-chart-view/components/ScoreChartViewPanel/ScoreChartViewPanel.tsx@@ -7,12 +7,13 @@ import {Loader2,} from "@langfuse/icons";import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";-import type { DataPoint } from "@/src/features/widgets";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";import { Button } from "@/src/components/ui/button";// Chart type picker is view-agnostic (only depends on `DashboardWidgetChartType`),// so it's reused as-is rather than duplicated.-import { ChartTypePicker, ChartCanvas } from "@/src/features/chart-view";+import { ChartTypePicker } from "@/src/features/chart-view/components/ConfigControls";+import { ChartCanvas } from "@/src/features/chart-view/components/ChartCanvas";import { type AggregationFn } from "@/src/features/chart-view/types";import { isTimeSeriesChartType } from "@/src/features/chart-view/vocab";import {diff --git a/web/src/features/scores-chart-view/components/ScoreOutlierBarStrip/ScoreOutlierBarStrip.tsx b/web/src/features/scores-chart-view/components/ScoreOutlierBarStrip/ScoreOutlierBarStrip.tsxindex eb2f48a457..b93f3dffda 100644--- a/web/src/features/scores-chart-view/components/ScoreOutlierBarStrip/ScoreOutlierBarStrip.tsx+++ b/web/src/features/scores-chart-view/components/ScoreOutlierBarStrip/ScoreOutlierBarStrip.tsx@@ -3,7 +3,7 @@ import { useCallback, useMemo, useRef, useState } from "react";import { X } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";import { Layer } from "@/src/components/design-system/Layer/Layer";-import { formatBucketRange } from "@/src/features/events";+import { formatBucketRange } from "@/src/features/events/components/outlier-strip/lib/binning";import { SCORE_OUTLIER_STRIP_METRICS } from "@/src/features/scores-chart-view/constants/scoreOutlierStripMetrics";import { prepareScoreOutlierYTicks } from "@/src/features/scores-chart-view/fns/binning/scoreOutlierBinning";import {diff --git a/web/src/features/scores-chart-view/components/ScoresChartView.tsx b/web/src/features/scores-chart-view/components/ScoresChartView.tsxindex c5c75fe92e..d8362c19be 100644--- a/web/src/features/scores-chart-view/components/ScoresChartView.tsx+++ b/web/src/features/scores-chart-view/components/ScoresChartView.tsx@@ -2,7 +2,7 @@ import React, { useMemo } from "react";import { type FilterState } from "@langfuse/shared";import { type ViewVersion } from "@langfuse/shared/query";import { api } from "@/src/utils/api";-import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard";+import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import { VIEW_BY_DATASET } from "@/src/features/scores-chart-view/constants/viewByDataset";import {buildScoresChartQuery,@@ -14,8 +14,8 @@ import { ScoreChartViewPanel } from "@/src/features/scores-chart-view/components// Shared with the observations chart view; only the widget-input mapper// passed to it (`scoreChartConfigToWidgetInput`) is scores-specific.-import { AddToDashboardButton } from "@/src/features/chart-view";-import { useHasProjectAccess } from "@/src/features/rbac";+import { AddToDashboardButton } from "@/src/features/chart-view/components/AddToDashboardButton";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";/*** Production chart view for the scores table. Mirrors `EventsChartView` (thediff --git a/web/src/features/scores-chart-view/components/ScoresOutlierStrip.tsx b/web/src/features/scores-chart-view/components/ScoresOutlierStrip.tsxindex 203e5808be..490779643d 100644--- a/web/src/features/scores-chart-view/components/ScoresOutlierStrip.tsx+++ b/web/src/features/scores-chart-view/components/ScoresOutlierStrip.tsx@@ -14,9 +14,9 @@ import {import {canReuseOutlierPlaceholder,pickChartGranularity,-} from "@/src/features/events";-import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+} from "@/src/features/events/components/outlier-strip/lib/binning";+import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { ScoreOutlierStripHeader } from "@/src/features/scores-chart-view/components/ScoreOutlierStripHeader";import { SCORE_OUTLIER_STRIP_METRICS } from "@/src/features/scores-chart-view/constants/scoreOutlierStripMetrics";import { canApplyScoreOutlierStripFilters } from "@/src/features/scores-chart-view/fns/outlierStripFilters";diff --git a/web/src/features/scores-chart-view/fns/binning/scoreOutlierBinning.ts b/web/src/features/scores-chart-view/fns/binning/scoreOutlierBinning.tsindex cf30a24885..ef1e0a46bb 100644--- a/web/src/features/scores-chart-view/fns/binning/scoreOutlierBinning.ts+++ b/web/src/features/scores-chart-view/fns/binning/scoreOutlierBinning.ts@@ -2,8 +2,8 @@ import { format } from "date-fns";import {OUTLIER_STRIP_STEP_LADDER_SECONDS,outlierStripResultColumn,-} from "@/src/features/events";-import { parseChartTimestamp } from "@/src/features/widgets";+} from "@/src/features/events/components/outlier-strip/lib/binning";+import { parseChartTimestamp } from "@/src/features/widgets/chart-library/prepareTimeAxis";import { SCORE_OUTLIER_STRIP_METRICS } from "@/src/features/scores-chart-view/constants/scoreOutlierStripMetrics";import {type ScoreOutlierBin,diff --git a/web/src/features/scores-chart-view/fns/outlierStripFilters.ts b/web/src/features/scores-chart-view/fns/outlierStripFilters.tsindex 5be3cc7e7d..5cef58c213 100644--- a/web/src/features/scores-chart-view/fns/outlierStripFilters.ts+++ b/web/src/features/scores-chart-view/fns/outlierStripFilters.ts@@ -1,5 +1,5 @@import { type FilterState } from "@langfuse/shared";-import { partitionStoredUiTableFiltersToView } from "@/src/features/dashboard";+import { partitionStoredUiTableFiltersToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";/*** Whether every active scores-table filter can be forwarded to the strip'sdiff --git a/web/src/features/scores-chart-view/fns/scoreChartConfig.ts b/web/src/features/scores-chart-view/fns/scoreChartConfig.tsindex 582569bfab..cc3713b6c6 100644--- a/web/src/features/scores-chart-view/fns/scoreChartConfig.ts+++ b/web/src/features/scores-chart-view/fns/scoreChartConfig.ts@@ -5,11 +5,9 @@ import {GRANULARITIES,isTimeSeriesChartType,} from "@/src/features/chart-view/vocab";-import { type ChartWidgetInput } from "@/src/features/chart-view";-import {- type DataPoint,- getWidgetMissingBucketValue,-} from "@/src/features/widgets";+import type { ChartWidgetInput } from "@/src/features/chart-view/lib/chartConfigToWidget";+import type { DataPoint } from "@/src/features/widgets/chart-library/chart-props";+import { getWidgetMissingBucketValue } from "@/src/features/widgets/utils";import { getScoreDimensionsForDataset } from "@/src/features/scores-chart-view/constants/scoreDimensions";import {getScoreMetricsForDataset,diff --git a/web/src/features/scores-chart-view/index.ts b/web/src/features/scores-chart-view/index.tsdeleted file mode 100644index 135fd03062..0000000000--- a/web/src/features/scores-chart-view/index.ts+++ /dev/null@@ -1,7 +0,0 @@-// Client-safe surface for this feature. Named re-exports only — see the-// project's code-structure RFC. Everything else in this feature is internal;-// import it through here.-export { ScoresChartView } from "@/src/features/scores-chart-view/components/ScoresChartView";-export { ScoresOutlierStrip } from "@/src/features/scores-chart-view/components/ScoresOutlierStrip";-export { useScoresChartViewState } from "@/src/features/scores-chart-view/hooks/useScoresChartViewState";-export { getScoreChartTimeRange } from "@/src/features/scores-chart-view/fns/scoreChartConfig";diff --git a/web/src/features/scores/ScoresAnalyticsPage.tsx b/web/src/features/scores/ScoresAnalyticsPage.tsxindex 556ad7d23c..d231b2d3f4 100644--- a/web/src/features/scores/ScoresAnalyticsPage.tsx+++ b/web/src/features/scores/ScoresAnalyticsPage.tsx@@ -2,15 +2,20 @@import { useRouter } from "next/router";import { useMemo, useEffect, useRef } from "react";import Page from "@/src/components/layouts/Page";-import { getScoresTabs, SCORES_TABS } from "@/src/features/navigation";import {- useAnalyticsUrlState,- type ScoreOption,+ getScoresTabs,+ SCORES_TABS,+} from "@/src/features/navigation/utils/scores-tabs";++import { useAnalyticsUrlState } from "@/src/features/score-analytics/lib/analytics-url-state";+import type { ScoreOption } from "@/src/features/score-analytics/components/charts/ScoreCombobox";+import {ScoreAnalyticsProvider,type DataType,- ScoreAnalyticsHeader,- ScoreAnalyticsDashboard,-} from "@/src/features/score-analytics";+} from "@/src/features/score-analytics/components/ScoreAnalyticsProvider";++import { ScoreAnalyticsHeader } from "@/src/features/score-analytics/components/ScoreAnalyticsHeader";+import { ScoreAnalyticsDashboard } from "@/src/features/score-analytics/components/ScoreAnalyticsDashboard";import { useDashboardDateRange } from "@/src/hooks/useDashboardDateRange";import {toAbsoluteTimeRange,diff --git a/web/src/features/scores/ScoresPage.tsx b/web/src/features/scores/ScoresPage.tsxindex 3f63089302..9e8b464fb0 100644--- a/web/src/features/scores/ScoresPage.tsx+++ b/web/src/features/scores/ScoresPage.tsx@@ -4,8 +4,11 @@ import { TablePeekViewTraceDetail } from "@/src/components/table/peek/TablePeekVimport Page from "@/src/components/layouts/Page";import { api } from "@/src/utils/api";import { ScoresOnboarding } from "@/src/components/onboarding/ScoresOnboarding";-import { getScoresTabs, SCORES_TABS } from "@/src/features/navigation";-import { useReadPath } from "@/src/features/events";+import {+ getScoresTabs,+ SCORES_TABS,+} from "@/src/features/navigation/utils/scores-tabs";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";export default function ScoresPage() {const router = useRouter();diff --git a/web/src/features/scores/ScoresTable.tsx b/web/src/features/scores/ScoresTable.tsxindex 0eeb948127..abd01e000e 100644--- a/web/src/features/scores/ScoresTable.tsx+++ b/web/src/features/scores/ScoresTable.tsx@@ -25,16 +25,15 @@ import { createTextTableColumn } from "@/src/components/design-system/table/coluimport { SearchableTableFilterLayout } from "@/src/components/table/resizable-filter-layout";import { type LangfuseColumnDef } from "@/src/components/table/types";import { ConnectedIOTableCell } from "@/src/components/table/ConnectedIOTableCell";-import {- useColumnVisibility,- useColumnOrder,-} from "@/src/features/column-visibility";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";import {type UseSidebarFilterStateOptions,useSidebarFilterState,- transformFiltersForBackend,- sortOptionValues,-} from "@/src/features/filters";+} from "@/src/features/filters/hooks/useSidebarFilterState";++import { transformFiltersForBackend } from "@/src/features/filters/lib/filter-transform";+import { sortOptionValues } from "@/src/features/filters/lib/option-sort";import { usePeekTableState } from "@/src/components/table/peek/contexts/PeekTableStateProvider";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";@@ -58,29 +57,25 @@ import {import { isNumericDataType } from "@/src/features/scores/lib/helpers";import { ScoresSearchBar } from "@/src/features/scores/components/ScoresSearchBar";-import {- getScoreChartTimeRange,- ScoresChartView,- ScoresOutlierStrip,- useScoresChartViewState,-} from "@/src/features/scores-chart-view";-import { useOrderByState } from "@/src/features/orderBy";+import { getScoreChartTimeRange } from "@/src/features/scores-chart-view/fns/scoreChartConfig";+import { ScoresChartView } from "@/src/features/scores-chart-view/components/ScoresChartView";+import { ScoresOutlierStrip } from "@/src/features/scores-chart-view/components/ScoresOutlierStrip";+import { useScoresChartViewState } from "@/src/features/scores-chart-view/hooks/useScoresChartViewState";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { useTableDateRange } from "@/src/hooks/useTableDateRange";import { toAbsoluteTimeRange } from "@/src/utils/date-range-utils";import { api } from "@/src/utils/api";import { TableHeaderControls } from "@/src/components/table/TableHeaderControls";import type { RouterOutput } from "@/src/utils/types";-import { TagList } from "@/src/features/tag";+import { default as TagList } from "@/src/features/tag/components/TagList";import { cn } from "@/src/utils/tailwind";import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";-import { showSuccessToast } from "@/src/features/notifications";-import {- TableActionMenu,- type TableAction,- useSelectAll,- TableSelectionManager,-} from "@/src/features/table";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";+import type { TableAction } from "@/src/features/table/types";+import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";import React, {type ReactNode,useState,@@ -89,19 +84,19 @@ import React, {useMemo,} from "react";import type { RowSelectionState } from "@tanstack/react-table";-import { useHasEntitlement } from "@/src/features/entitlements";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";import { createIdTableColumn } from "@/src/components/design-system/table/columns/createIdTableColumn";import { usePaginationState } from "@/src/hooks/usePaginationState";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import {ScoreTag,scoreLevelFromScore,type ScoreLevel,} from "@/src/components/ScoreTag";-import { ViewModeToggle } from "@/src/features/chart-view";+import { ViewModeToggle } from "@/src/features/chart-view/components/ViewModeToggle";export type ScoresTableRow = {id: string;diff --git a/web/src/features/scores/adapters/index.ts b/web/src/features/scores/adapters/index.tsindex 2689b11c26..c66282e563 100644--- a/web/src/features/scores/adapters/index.ts+++ b/web/src/features/scores/adapters/index.ts@@ -1,7 +1,7 @@import {transformCategoricalScoresToChartData,uniqueAndSort,-} from "@/src/features/dashboard";+} from "@/src/features/dashboard/lib/score-analytics-utils";import {type ChartBin,type ChartData,diff --git a/web/src/features/scores/components/AddScoreCategoryDialog.tsx b/web/src/features/scores/components/AddScoreCategoryDialog.tsxindex 6c9ed2f04a..41cde73055 100644--- a/web/src/features/scores/components/AddScoreCategoryDialog.tsx+++ b/web/src/features/scores/components/AddScoreCategoryDialog.tsx@@ -14,10 +14,10 @@ import {import { Input } from "@/src/components/ui/input";import { Label } from "@/src/components/ui/label";import { api } from "@/src/utils/api";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { validateNewCategoryLabel } from "@/src/features/scores/lib/annotationFormHelpers";import { type AnnotationAnalyticsContext } from "@/src/features/scores/lib/annotationAnalytics";-import { showToast } from "@/src/features/notifications";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";export function AddScoreCategoryDialog({diff --git a/web/src/features/scores/components/AnnotateDrawerController.tsx b/web/src/features/scores/components/AnnotateDrawerController.tsxindex 585654b20d..8230eaef19 100644--- a/web/src/features/scores/components/AnnotateDrawerController.tsx+++ b/web/src/features/scores/components/AnnotateDrawerController.tsx@@ -1,10 +1,10 @@-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {DrawerContent,DrawerController,DrawerTitle,} from "@/src/components/ui/drawer";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {type ScoreTarget,type AnnotationPanelData,diff --git a/web/src/features/scores/components/AnnotationForm.tsx b/web/src/features/scores/components/AnnotationForm.tsxindex 6ff91b94de..bac531e906 100644--- a/web/src/features/scores/components/AnnotationForm.tsx+++ b/web/src/features/scores/components/AnnotationForm.tsx@@ -9,7 +9,7 @@ import { Skeleton } from "@/src/components/ui/skeleton";import Header from "@/src/components/layouts/header";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";import { KeyboardShortcut } from "@/src/components/design-system/KeyboardShortcut/KeyboardShortcut";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {formatAnnotateDescription,isTextDataType,diff --git a/web/src/features/scores/components/CategoricalScoreInput.tsx b/web/src/features/scores/components/CategoricalScoreInput.tsxindex 35f5c695ff..1a03efac89 100644--- a/web/src/features/scores/components/CategoricalScoreInput.tsx+++ b/web/src/features/scores/components/CategoricalScoreInput.tsx@@ -8,7 +8,7 @@ import { Button } from "@/src/components/ui/button";import { Combobox } from "@/src/components/ui/Combobox";import { KeyboardShortcut } from "@/src/components/design-system/KeyboardShortcut/KeyboardShortcut";import { Tabs } from "@/src/components/design-system/Tabs/Tabs";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { isCategoricalDataType } from "@/src/features/scores/lib/helpers";import { getAddCategoryActionLabel } from "@/src/features/scores/lib/annotationFormHelpers";import { AddScoreCategoryDialog } from "@/src/features/scores/components/AddScoreCategoryDialog";diff --git a/web/src/features/scores/components/DualAnnotationContent.clienttest.tsx b/web/src/features/scores/components/DualAnnotationContent.clienttest.tsxindex f4069974a2..735aabb1ec 100644--- a/web/src/features/scores/components/DualAnnotationContent.clienttest.tsx+++ b/web/src/features/scores/components/DualAnnotationContent.clienttest.tsx@@ -64,14 +64,16 @@ vi.mock("@/src/components/layouts/header", async (importOriginal) => {};});-vi.mock("@/src/features/rbac", () => ({+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({useHasProjectAccess: () => mocks.hasConfigAccess,}));-vi.mock("@/src/features/notifications", () => ({ showErrorToast: vi.fn() }));+vi.mock("@/src/features/notifications/showErrorToast", () => ({+ showErrorToast: vi.fn(),+}));vi.mock("@/src/features/scores/hooks/useScoreEditsDisabled", () => ({useScoreEditsDisabled: () => mocks.scoreEditsDisabled,}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => mocks.capture,}));vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({diff --git a/web/src/features/scores/components/ScoreRow.tsx b/web/src/features/scores/components/ScoreRow.tsxindex 90483c3e96..9ce54f8ab6 100644--- a/web/src/features/scores/components/ScoreRow.tsx+++ b/web/src/features/scores/components/ScoreRow.tsx@@ -14,7 +14,8 @@ import {import { api } from "@/src/utils/api";import { JSONView } from "@/src/components/ui/CodeJsonViewer";import { Skeleton } from "@/src/components/ui/skeleton";-import { type BaselineDiff, DiffLabel } from "@/src/features/datasets";+import type { BaselineDiff } from "@/src/features/datasets/lib/calculateBaselineDiff";+import { DiffLabel } from "@/src/features/datasets/components/DiffLabel";const resolveScoreValue = (aggregate: AggregatedScoreData): string => {if (aggregate.type === "NUMERIC") {diff --git a/web/src/features/scores/components/ScoresSearchBar.tsx b/web/src/features/scores/components/ScoresSearchBar.tsxindex eedce0c62a..1a92048e95 100644--- a/web/src/features/scores/components/ScoresSearchBar.tsx+++ b/web/src/features/scores/components/ScoresSearchBar.tsx@@ -1,11 +1,9 @@import type { FilterState } from "@langfuse/shared";import { useMemo } from "react";-import type { FilterConfig } from "@/src/features/filters";-import {- type ComposerSize,- TableSearchBar,- toObservedOptions,-} from "@/src/features/search-bar";+import type { FilterConfig } from "@/src/features/filters/lib/filter-config";+import type { ComposerSize } from "@/src/features/search-bar/components/ComposerSurface";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { scoresFieldRegistry } from "@/src/features/scores/constants/scoresSearchRegistry";diff --git a/web/src/features/scores/constants/scoresSearchRegistry.ts b/web/src/features/scores/constants/scoresSearchRegistry.tsindex 3ee39a3dc1..d8f97b8549 100644--- a/web/src/features/scores/constants/scoresSearchRegistry.ts+++ b/web/src/features/scores/constants/scoresSearchRegistry.ts@@ -1,6 +1,6 @@import { getScoreFilterConfig } from "@/src/features/filters/config/scores-config";-import type { FilterConfig } from "@/src/features/filters";-import { fieldRegistryFromColumns } from "@/src/features/search-bar";+import type { FilterConfig } from "@/src/features/filters/lib/filter-config";+import { fieldRegistryFromColumns } from "@/src/features/search-bar/lib/fields";export function scoresFieldRegistry(config: FilterConfig) {const facetColumns = new Set(config.facets.map((facet) => facet.column));diff --git a/web/src/features/scores/hooks/useScoreMutations.ts b/web/src/features/scores/hooks/useScoreMutations.tsindex 5ec12b1251..87eb0263ab 100644--- a/web/src/features/scores/hooks/useScoreMutations.ts+++ b/web/src/features/scores/hooks/useScoreMutations.ts@@ -4,7 +4,7 @@ import {isTraceScore,} from "@/src/features/scores/lib/helpers";import { useScoreCache } from "@/src/features/scores/contexts/ScoreCacheProvider";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";export function useScoreMutations() {diff --git a/web/src/features/scores/index.ts b/web/src/features/scores/index.tsdeleted file mode 100644index 7c5382ddfe..0000000000--- a/web/src/features/scores/index.ts+++ /dev/null@@ -1,82 +0,0 @@-// The scores feature's public client surface (RFC rule 8). Named re-exports-// only — the list is exactly what other features already imported, nothing-// added for the future.-//-// Dual-use modules (aggregateScores, scoreColumns, helpers, scoresSearchRegistry)-// stay a deep import for server callers. This door already carries React UI-// (AnnotationForm, ScoresTable), and routing those files through here would-// pull that UI into tRPC routers. Client importers of the same files come-// through this door; server importers keep the file path.-//-// annotationFormHelpers stays deep: its only external importer is the-// scoreConfigs tRPC router.-export {- CompareViewAdapter,- DashboardCategoricalScoreAdapter,-} from "@/src/features/scores/adapters";-export { AnnotateDrawerController } from "@/src/features/scores/components/AnnotateDrawerController";-export { AnnotationForm } from "@/src/features/scores/components/AnnotationForm";-export { ScoreRow } from "@/src/features/scores/components/ScoreRow";-export { MultiSelectKeyValues } from "@/src/features/scores/components/MultiSelectKeyValues";-export {- ScoreCacheProvider,- type CachedScore,-} from "@/src/features/scores/contexts/ScoreCacheProvider";-export { useEmptyScoreConfigs } from "@/src/features/scores/hooks/useEmptyConfigs";-export {- createScoreColumns,- useScoreColumns,-} from "@/src/features/scores/hooks/useScoreColumns";-export {- aggregateScores,- collectScoreNameCoverage,- composeAggregateScoreKey,- decomposeAggregateScoreKey,- getScoreLabelFromKey,- normalizeScoreName,- type ScoreToAggregate,-} from "@/src/features/scores/lib/aggregateScores";-export {- formatScoreRange,- isBooleanDataType,- isCategoricalDataType,- isNumericDataType,- isTextDataType,-} from "@/src/features/scores/lib/helpers";-export {- hasModifier,- isCompleteShortcut,- isInteractiveTarget,- isOpenDialogPresent,- isTypingTarget,-} from "@/src/features/scores/lib/keyboardShortcuts";-export { useMergeScoreColumns } from "@/src/features/scores/lib/mergeScoreColumns";-export {- mergeAggregatesWithCache,- mergeAnnotationScoresWithCache,- mergeScoresWithCache,-} from "@/src/features/scores/lib/mergeScoresWithCache";-export {- addPrefixToScoreKeys,- collectPresentScoreKeys,- convertScoreColumnsToAnalyticsData,- getScoreDataTypeExplanation,- getScoreDataTypeIcon,- revealScoreColumns,- scoreFilters,- splitScoreDataTypeIcon,- withPresentScoreKeys,-} from "@/src/features/scores/lib/scoreColumns";-export { transformToAnnotationScores } from "@/src/features/scores/lib/transformScores";-export { useMergedAggregates } from "@/src/features/scores/lib/useMergedAggregates";-export { useMergedScores } from "@/src/features/scores/lib/useMergedScores";-export type {- AnnotationScore,- CategoryCounts,- ChartBin,- ScoreColumn,- ScoreData,- ScoreTarget,-} from "@/src/features/scores/types";--export { default as ScoresTable } from "@/src/features/scores/ScoresTable";diff --git a/web/src/features/scores/server/index.ts b/web/src/features/scores/server/index.tsdeleted file mode 100644index 1ce33ddf6a..0000000000--- a/web/src/features/scores/server/index.ts+++ /dev/null@@ -1,12 +0,0 @@-// Dual-use scores helpers for server callers (RFC rule 8 / rule 10).-// The client door already re-exports these for UI; tRPC routers and public-// API services reach them here so they do not load AnnotationForm / ScoresTable.-export {- aggregateScores,- composeAggregateScoreKey,-} from "@/src/features/scores/lib/aggregateScores";-export {- isBooleanDataType,- isNumericDataType,- isTraceScore,-} from "@/src/features/scores/lib/helpers";diff --git a/web/src/features/sdk-version/index.ts b/web/src/features/sdk-version/index.tsdeleted file mode 100644index c7d3fb1750..0000000000--- a/web/src/features/sdk-version/index.ts+++ /dev/null@@ -1,13 +0,0 @@-// The sdk-version feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-//-// Server callers of getSdkVersionCapabilityStatus use server/index.ts-// so they do not load the React hook on this door.-export { useProjectSdkVersionInfo } from "@/src/features/sdk-version/hooks/useProjectSdkVersionInfo";-export {- getSdkVersionCapability,- getSdkVersionCapabilityStatus,- toSdkVersionInfo,- type SdkVersionInfo,-} from "@/src/features/sdk-version/lib/sdkVersionCapabilities";-export { clearProjectSdkVersionInfo } from "@/src/features/sdk-version/lib/sdkVersionStorage";diff --git a/web/src/features/sdk-version/server/index.ts b/web/src/features/sdk-version/server/index.tsdeleted file mode 100644index ca944b2322..0000000000--- a/web/src/features/sdk-version/server/index.ts+++ /dev/null@@ -1,3 +0,0 @@-// The sdk-version feature's server surface (RFC rule 9, amended): the-// capability helper server callers already imported by file path.-export { getSdkVersionCapabilityStatus } from "@/src/features/sdk-version/lib/sdkVersionCapabilities";diff --git a/web/src/features/search-bar/components/ComposerTokens.tsx b/web/src/features/search-bar/components/ComposerTokens.tsxindex 80aa63af8f..25fb6e84a0 100644--- a/web/src/features/search-bar/components/ComposerTokens.tsx+++ b/web/src/features/search-bar/components/ComposerTokens.tsx@@ -23,7 +23,7 @@ import {} from "@/src/features/search-bar/lib/composer-segments";import { indexOfOutsideQuotes } from "@/src/features/search-bar/lib/langQ";import { deactivationReason } from "@/src/features/search-bar/components/presentation";-import { FilterToken } from "@/src/features/filters";+import { FilterToken } from "@/src/features/filters/components/FilterToken";// Word joiner around pills: gives the DOM caret boundaries between tokens// without changing the query text. Stripped before the text reaches the modeldiff --git a/web/src/features/search-bar/components/EventsSearchBarRow.tsx b/web/src/features/search-bar/components/EventsSearchBarRow.tsxindex b231f15583..a5e4b4ee53 100644--- a/web/src/features/search-bar/components/EventsSearchBarRow.tsx+++ b/web/src/features/search-bar/components/EventsSearchBarRow.tsx@@ -17,7 +17,7 @@import * as React from "react";import { type FilterState } from "@langfuse/shared";-import { useQueryProject } from "@/src/features/projects";+import { useQueryProject } from "@/src/features/projects/hooks";import { cn } from "@/src/utils/tailwind";import type {ObservedOptions,diff --git a/web/src/features/search-bar/components/SearchBarAiPrompt.tsx b/web/src/features/search-bar/components/SearchBarAiPrompt.tsxindex 49e7256009..ce9ce551f8 100644--- a/web/src/features/search-bar/components/SearchBarAiPrompt.tsx+++ b/web/src/features/search-bar/components/SearchBarAiPrompt.tsx@@ -22,12 +22,12 @@ import { useStore } from "zustand";import { type FilterState } from "@langfuse/shared";import type { FieldRegistry } from "@/src/features/search-bar/lib/fields";import { KeyboardShortcut } from "@/src/components/design-system/KeyboardShortcut/KeyboardShortcut";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import type { ObservedScoreNames } from "@/src/features/search-bar/lib/observed-options";import type { SearchBarStore } from "@/src/features/search-bar/store/searchBarStore";import { api } from "@/src/utils/api";import { cn } from "@/src/utils/tailwind";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";// "No such score X" note for score filters the server dropped because their// name matches no observed score (exactly or normalized).diff --git a/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx b/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsxindex 04114d287e..755a9bc35e 100644--- a/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx+++ b/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx@@ -12,7 +12,7 @@ import * as recentSearches from "@/src/features/search-bar/lib/recent-searches";afterEach(() => vi.restoreAllMocks());const { capture } = vi.hoisted(() => ({ capture: vi.fn() }));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => capture,}));beforeEach(() => capture.mockClear());diff --git a/web/src/features/search-bar/hooks/useEventsSearchBar.ts b/web/src/features/search-bar/hooks/useEventsSearchBar.tsindex 83620a518c..098651dac1 100644--- a/web/src/features/search-bar/hooks/useEventsSearchBar.ts+++ b/web/src/features/search-bar/hooks/useEventsSearchBar.ts@@ -43,7 +43,7 @@ import {createSearchBarStore,type SearchBarStore,} from "@/src/features/search-bar/store/searchBarStore";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";/** How a search-bar commit was triggered — the `trigger` analytics dimension. */type SearchCommitTrigger = "enter" | "blur" | "pick";diff --git a/web/src/features/search-bar/index.ts b/web/src/features/search-bar/index.tsdeleted file mode 100644index fe61f37b63..0000000000--- a/web/src/features/search-bar/index.ts+++ /dev/null@@ -1,47 +0,0 @@-// The search-bar feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-//-// filters' sessions/users/tracing search registries keep importing-// `lib/fields` by file path: they live on the filters door, and this-// index re-exports ComposerTokens which already imports that door, so-// routing those registries through here would close a runtime cycle.-export { ComposerTokens } from "@/src/features/search-bar/components/ComposerTokens";-export { EventsSearchBarRow } from "@/src/features/search-bar/components/EventsSearchBarRow";-export { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";-export {- type ComposerSize,- ComposerSurface,- ComposerText,-} from "@/src/features/search-bar/components/ComposerSurface";-export { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";-export { useSearchBarEnabled } from "@/src/features/search-bar/hooks/useSearchBarEnabled";-export { useFullTextSearch } from "@/src/features/search-bar/hooks/useFullTextSearch";-export { astToFilterState } from "@/src/features/search-bar/lib/adapter";-export { buildAiContext } from "@/src/features/search-bar/lib/ai-context";-export { planCommit } from "@/src/features/search-bar/lib/commit";-export {- applyPick,- planInputCompletions,-} from "@/src/features/search-bar/lib/completions";-export type { QueryPresetSection } from "@/src/features/search-bar/lib/completions";-export {- EVENTS_FIELD_REGISTRY,- createFieldRegistry,- extendFieldRegistryWithColumns,- fieldRegistryFromColumns,- resolveField,- withFieldOptions,-} from "@/src/features/search-bar/lib/fields";-export type { FieldRegistry } from "@/src/features/search-bar/lib/fields";-export { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";-export { parse } from "@/src/features/search-bar/lib/langQ";-export {- observedScoreNamesFromOptions,- toObservedOptions,- withMetadataPathOptions,-} from "@/src/features/search-bar/lib/observed-options";-export type { ObservedOptions } from "@/src/features/search-bar/lib/observed-options";-export { filterRank } from "@/src/features/search-bar/lib/rank";-export { runSearchBarInvariants } from "@/src/features/search-bar/lib/searchBarInvariants";-export { validateQuery } from "@/src/features/search-bar/lib/validate";-export { createSearchBarStore } from "@/src/features/search-bar/store/searchBarStore";diff --git a/web/src/features/search-bar/lib/adapter.clienttest.ts b/web/src/features/search-bar/lib/adapter.clienttest.tsindex 0536f9ca4b..18debf5fc0 100644--- a/web/src/features/search-bar/lib/adapter.clienttest.ts+++ b/web/src/features/search-bar/lib/adapter.clienttest.ts@@ -13,7 +13,7 @@ import {import {USERS_FIELD_REGISTRY,LEGACY_USERS_FIELD_REGISTRY,-} from "@/src/features/filters";+} from "@/src/features/filters/config/usersSearchRegistry";const scopedRegistry = createFieldRegistry({...EVENTS_FIELD_REGISTRY,diff --git a/web/src/features/search-bar/lib/explain.clienttest.ts b/web/src/features/search-bar/lib/explain.clienttest.tsindex 536cdaec78..dcaad985e6 100644--- a/web/src/features/search-bar/lib/explain.clienttest.ts+++ b/web/src/features/search-bar/lib/explain.clienttest.ts@@ -3,7 +3,7 @@import { deriveComposerSegments } from "@/src/features/search-bar/lib/composer-segments";import { explainSegment } from "@/src/features/search-bar/lib/explain";import { FIELDS } from "@/src/features/search-bar/lib/fields";-import { SESSIONS_FIELD_REGISTRY } from "@/src/features/filters";+import { SESSIONS_FIELD_REGISTRY } from "@/src/features/filters/config/sessionsSearchRegistry";import { SCORES_FIELD_REGISTRY } from "@/src/features/scores/constants/scoresSearchRegistry";/** Explain the nth token of `query` as the tooltip reads it. */diff --git a/web/src/features/search-bar/lib/searchBarInvariants.clienttest.ts b/web/src/features/search-bar/lib/searchBarInvariants.clienttest.tsindex 413340cfba..109bbeddd2 100644--- a/web/src/features/search-bar/lib/searchBarInvariants.clienttest.ts+++ b/web/src/features/search-bar/lib/searchBarInvariants.clienttest.ts@@ -15,10 +15,12 @@ import {import {SESSIONS_FIELD_REGISTRY,sessionsFieldRegistry,- getSessionFilterConfig,+} from "@/src/features/filters/config/sessionsSearchRegistry";+import { getSessionFilterConfig } from "@/src/features/filters/config/sessions-config";+import {USERS_FIELD_REGISTRY,LEGACY_USERS_FIELD_REGISTRY,-} from "@/src/features/filters";+} from "@/src/features/filters/config/usersSearchRegistry";import { usersEventsFilterConfig } from "@/src/features/filters/config/users-config";diff --git a/web/src/features/search-bar/server/resolveFilterPrompt.ts b/web/src/features/search-bar/server/resolveFilterPrompt.tsindex 7527fc42fa..5c7fc14162 100644--- a/web/src/features/search-bar/server/resolveFilterPrompt.ts+++ b/web/src/features/search-bar/server/resolveFilterPrompt.ts@@ -44,7 +44,7 @@ import {logger,} from "@langfuse/shared/src/server";import type { ChatPromptClient } from "langfuse";-import { getLangfuseClient } from "@/src/features/natural-language-filters/server";+import { getLangfuseClient } from "@/src/features/natural-language-filters/server/utils";import {buildFieldCatalog,buildFilterSystemPrompt,diff --git a/web/src/features/search-bar/server/router.ts b/web/src/features/search-bar/server/router.tsindex 94d00ebd55..051b2adaab 100644--- a/web/src/features/search-bar/server/router.ts+++ b/web/src/features/search-bar/server/router.ts@@ -35,7 +35,7 @@ import {import { env } from "@/src/env.mjs";import { randomBytes } from "crypto";import { z } from "zod";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {MAX_SCORE_NAME_LENGTH,MAX_SCORE_NAMES_PER_TYPE,@@ -54,10 +54,8 @@ import {RULE_SAMPLE_FIELD_REGISTRY,} from "@/src/features/evals/v2/constants/evaluatorSearchRegistry";import { DATASET_NAME_COLUMN } from "@/src/features/evals/v2/utils/datasetNameFilter";-import {- SESSIONS_FIELD_REGISTRY,- USERS_FIELD_REGISTRY,-} from "@/src/features/filters";+import { SESSIONS_FIELD_REGISTRY } from "@/src/features/filters/config/sessionsSearchRegistry";+import { USERS_FIELD_REGISTRY } from "@/src/features/filters/config/usersSearchRegistry";import { SCORES_FIELD_REGISTRY } from "@/src/features/scores/constants/scoresSearchRegistry";diff --git a/web/src/features/sessions/ConnectedSessionAddToDropdownMenuController.tsx b/web/src/features/sessions/ConnectedSessionAddToDropdownMenuController.tsxindex 1df2282560..25f05cf14f 100644--- a/web/src/features/sessions/ConnectedSessionAddToDropdownMenuController.tsx+++ b/web/src/features/sessions/ConnectedSessionAddToDropdownMenuController.tsx@@ -2,7 +2,7 @@ import { AnnotationQueueObjectType } from "@langfuse/shared";import { type ComponentProps, type ReactNode } from "react";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";-import { AnnotationQueueSubmenuItemController } from "@/src/features/annotation-queues";+import { AnnotationQueueSubmenuItemController } from "@/src/features/annotation-queues/components/AnnotationQueueSubmenuItemController";import { type AnalyticsData } from "@/src/features/scores/types";type TriggerControls = Parameters<diff --git a/web/src/features/sessions/LazySessionTraceEventsRow.tsx b/web/src/features/sessions/LazySessionTraceEventsRow.tsxindex be0836c10f..76100f0b45 100644--- a/web/src/features/sessions/LazySessionTraceEventsRow.tsx+++ b/web/src/features/sessions/LazySessionTraceEventsRow.tsx@@ -8,7 +8,7 @@ import {import { useSessionDetailStore } from "@/src/features/sessions/SessionDetailStoreProvider";import { type RouterOutputs } from "@/src/utils/api";import { type FilterState } from "@langfuse/shared";-import { type IOPreviewContentMode } from "@/src/features/traces";+import type { IOPreviewContentMode } from "@/src/features/traces/components/IOPreview/IOPreview";type LazySessionTraceEventsRowProps = {trace: RouterOutputs["sessions"]["tracesFromEvents"][number];diff --git a/web/src/features/sessions/ModernSessionFilterControls.tsx b/web/src/features/sessions/ModernSessionFilterControls.tsxindex 415816f401..11a1bb18a5 100644--- a/web/src/features/sessions/ModernSessionFilterControls.tsx+++ b/web/src/features/sessions/ModernSessionFilterControls.tsx@@ -27,8 +27,8 @@ import type { useTableViewManager } from "@/src/components/table/table-view-presimport { useViewData } from "@/src/components/table/table-view-presets/hooks/useViewData";import { useViewMutations } from "@/src/components/table/table-view-presets/hooks/useViewMutations";import { Dialog } from "@/src/components/ui/dialog";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";type ViewControllers = Pick<ReturnType<typeof useTableViewManager>,diff --git a/web/src/features/sessions/ModernSessionFilterDialogContent.tsx b/web/src/features/sessions/ModernSessionFilterDialogContent.tsxindex 2e5996c664..1870e7fb19 100644--- a/web/src/features/sessions/ModernSessionFilterDialogContent.tsx+++ b/web/src/features/sessions/ModernSessionFilterDialogContent.tsx@@ -10,7 +10,7 @@ import {DialogHeader,DialogTitle,} from "@/src/components/ui/dialog";-import { InlineFilterBuilder } from "@/src/features/filters";+import { InlineFilterBuilder } from "@/src/features/filters/components/filter-builder";export type ModernSessionFilterDialogViewActions =| { type: "none" }diff --git a/web/src/features/sessions/ModernSessionHeader.tsx b/web/src/features/sessions/ModernSessionHeader.tsxindex 4bd8537043..37e98d3151 100644--- a/web/src/features/sessions/ModernSessionHeader.tsx+++ b/web/src/features/sessions/ModernSessionHeader.tsx@@ -37,7 +37,7 @@ import {import { formatIntervalSeconds } from "@/src/utils/dates";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";import { numberFormatter } from "@/src/utils/numbers";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";type ModernSessionHeaderProps = {dividerTone: "default" | "orange";diff --git a/web/src/features/sessions/ModernSessionHeaderActionsController.clienttest.tsx b/web/src/features/sessions/ModernSessionHeaderActionsController.clienttest.tsxindex 586f21ba07..69772b47fd 100644--- a/web/src/features/sessions/ModernSessionHeaderActionsController.clienttest.tsx+++ b/web/src/features/sessions/ModernSessionHeaderActionsController.clienttest.tsx@@ -18,9 +18,12 @@ const {}));vi.mock("next-auth/react", () => ({ useSession: mockUseSession }));-vi.mock("@/src/features/feature-flags", () => ({- useInternalFeaturesEnabled: mockInternalFeaturesEnabled,-}));+vi.mock(+ "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled",+ () => ({+ useInternalFeaturesEnabled: mockInternalFeaturesEnabled,+ }),+);vi.mock("next/router", () => ({useRouter: () => ({ asPath: "/", push: vi.fn() }),diff --git a/web/src/features/sessions/ModernSessionHeaderActionsController.tsx b/web/src/features/sessions/ModernSessionHeaderActionsController.tsxindex fab15d61fd..a835923bd3 100644--- a/web/src/features/sessions/ModernSessionHeaderActionsController.tsx+++ b/web/src/features/sessions/ModernSessionHeaderActionsController.tsx@@ -1,6 +1,6 @@import { CopyIcon, MoreVertical } from "@langfuse/icons";import { useSession } from "next-auth/react";-import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";import { HeaderActionButton } from "@/src/components/HeaderActionButton";import { HeaderActionMenuRows } from "@/src/components/HeaderActionMenuRows";@@ -9,7 +9,7 @@ import {type DropdownMenuItemDefinition,} from "@/src/components/design-system/DropdownMenu/DropdownMenu";import { useShareMenuItems } from "@/src/components/useShareMenuItems";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { ConnectedDetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";diff --git a/web/src/features/sessions/ModernSessionSidebar.tsx b/web/src/features/sessions/ModernSessionSidebar.tsxindex 862aae4f7f..63fa48b0e1 100644--- a/web/src/features/sessions/ModernSessionSidebar.tsx+++ b/web/src/features/sessions/ModernSessionSidebar.tsx@@ -37,11 +37,9 @@ import {TooltipContent,TooltipTrigger,} from "@/src/components/ui/tooltip";-import { InlineFilterState } from "@/src/features/filters";-import {- ComposerTokens,- filterStateToQueryText,-} from "@/src/features/search-bar";+import { InlineFilterState } from "@/src/features/filters/components/filter-builder";+import { ComposerTokens } from "@/src/features/search-bar/components/ComposerTokens";+import { filterStateToQueryText } from "@/src/features/search-bar/lib/filter-state-to-query";import { formatIntervalSeconds } from "@/src/utils/dates";import { cn } from "@/src/utils/tailwind";diff --git a/web/src/features/sessions/SessionDetailPage.tsx b/web/src/features/sessions/SessionDetailPage.tsxindex 362c3d2fce..7274d42edf 100644--- a/web/src/features/sessions/SessionDetailPage.tsx+++ b/web/src/features/sessions/SessionDetailPage.tsx@@ -2,7 +2,7 @@ import {SessionEventsPage,SessionPage,} from "@/src/features/sessions/SessionPages";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { RouteParamsPendingFallback } from "@/src/components/RouteParamsPendingFallback/RouteParamsPendingFallback";import { useReadyRouteParams } from "@/src/hooks/useReadyRouteParams";diff --git a/web/src/features/sessions/SessionObservationIO.clienttest.tsx b/web/src/features/sessions/SessionObservationIO.clienttest.tsxindex 8be6fd218b..6e0dfd6132 100644--- a/web/src/features/sessions/SessionObservationIO.clienttest.tsx+++ b/web/src/features/sessions/SessionObservationIO.clienttest.tsx@@ -32,7 +32,16 @@ vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({// The component imports IOPreview through the traces feature surface, so the// mock has to intercept the surface — mocking the module behind it does nothing.-vi.mock("@/src/features/traces", () => ({+vi.mock("@/src/features/traces/components/IOPreview/IOPreview", () => ({+ IOPreview: ({ media }: { media?: { mediaId: string }[] }) => (+ <div+ data-testid="io-preview"+ data-media-ids={(media ?? []).map((m) => m.mediaId).join(",")}+ />+ ),+ useMedia: (args: Record<string, unknown>) => useMediaMock(args),+}));+vi.mock("@/src/features/traces/hooks/useMedia", () => ({IOPreview: ({ media }: { media?: { mediaId: string }[] }) => (<divdata-testid="io-preview"diff --git a/web/src/features/sessions/SessionObservationIO.tsx b/web/src/features/sessions/SessionObservationIO.tsxindex 24073a5880..6c3f33ca39 100644--- a/web/src/features/sessions/SessionObservationIO.tsx+++ b/web/src/features/sessions/SessionObservationIO.tsx@@ -3,18 +3,22 @@ import { Download, ExternalLinkIcon, Loader2 } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";import {IOPreview,- useMedia,- type ChatMLParserResult,type IOPreviewContentMode,type ViewMode,-} from "@/src/features/traces";+} from "@/src/features/traces/components/IOPreview/IOPreview";+import { useMedia } from "@/src/features/traces/hooks/useMedia";+import type { ChatMLParserResult } from "@/src/features/traces/hooks/useChatMLParser";+import { api, type RouterOutputs } from "@/src/utils/api";import { downloadJsonFile } from "@/src/features/sessions/actions/downloadSessionAsJson";-import { showErrorToast } from "@/src/features/notifications";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { compactNumberFormatter } from "@/src/utils/numbers";-import { decodeUnicodeEscapesOnly } from "@/src/utils/unicode";-import { parseJsonIfString, type ScoreDomain } from "@langfuse/shared";+import {+ decodeUnicodeEscapesOnly,+ parseJsonIfString,+ type ScoreDomain,+} from "@langfuse/shared";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";export type SessionTraceObservation =diff --git a/web/src/features/sessions/SessionPages.tsx b/web/src/features/sessions/SessionPages.tsxindex cfee311852..0b9fcd0e8c 100644--- a/web/src/features/sessions/SessionPages.tsx+++ b/web/src/features/sessions/SessionPages.tsx@@ -8,13 +8,11 @@ import { Spinner } from "@/src/components/design-system/Spinner/Spinner";import { Skeleton } from "@/src/components/ui/skeleton";import { SessionReviewLeading } from "@/src/features/sessions/SessionReviewLeadingProvider";import { PublishSessionSwitch } from "@/src/components/PublishSessionSwitch";-import { IOPreview } from "@/src/features/traces";+import { IOPreview } from "@/src/features/traces/components/IOPreview/IOPreview";import { JsonSkeleton } from "@/src/components/ui/CodeJsonViewer";import { Badge } from "@/src/components/design-system/Badge/Badge";-import {- DetailPageNav,- useDetailPageLists,-} from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { api, shouldRetryResourceQuery } from "@/src/utils/api";import { usdFormatter } from "@/src/utils/numbers";import { getNumberFromMap } from "@/src/utils/map-utils";@@ -28,14 +26,17 @@ import React, {useRef,} from "react";import { useVirtualizer } from "@tanstack/react-virtual";-import { AnnotateDrawerController } from "@/src/features/scores";-import { type AnnotateDrawerPayload } from "@/src/features/scores/components/AnnotateDrawerController";+import {+ AnnotateDrawerController,+ type AnnotateDrawerPayload,+} from "@/src/features/scores/components/AnnotateDrawerController";+import { ActionButtonCountBadge } from "@/src/components/ui/ActionButtonCountBadge";import { Button } from "@/src/components/ui/button";import {CommentDrawerController,getCommentDrawerInitialStateFromUrl,-} from "@/src/features/comments";+} from "@/src/features/comments/CommentDrawerController";import { useSession } from "next-auth/react";import {CheckIcon,@@ -50,7 +51,7 @@ import {} from "@langfuse/icons";import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import Page from "@/src/components/layouts/Page";import {Popover,@@ -66,14 +67,12 @@ import {TableViewPresetTableName,normalizeLegacySessionPositionInTraceFilters,} from "@langfuse/shared";-import {- AnnotationQueueItemDropdownMenuController,- AnnotationQueueItemCountBadge,-} from "@/src/features/annotation-queues";+import { AnnotationQueueItemDropdownMenuController } from "@/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController";+import { AnnotationQueueItemCountBadge } from "@/src/features/annotation-queues/components/AnnotationQueueItemCountBadge";import {useWebCalloutAction,WebCalloutButton,-} from "@/src/features/web-callouts";+} from "@/src/features/web-callouts/components/WebCalloutButton";import { TablePeekViewTraceDetail } from "@/src/components/table/peek/TablePeekViewTraceDetail";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";@@ -82,17 +81,17 @@ import { useParsedTrace } from "@/src/hooks/useParsedTrace";import useLocalStorage from "@/src/components/useLocalStorage";import { Switch } from "@/src/components/design-system/Switch/Switch";import { LazySessionTraceEventsRow } from "@/src/features/sessions/LazySessionTraceEventsRow";-import {- observationEventsFilterConfig,- useEventsFilterOptions,-} from "@/src/features/events";+import { observationEventsFilterConfig } from "@/src/features/events/config/filter-config";+import { useEventsFilterOptions } from "@/src/features/events/hooks/useEventsFilterOptions";import {decodeAndNormalizeFilters,useSidebarFilterState,+} from "@/src/features/filters/hooks/useSidebarFilterState";+import {buildSidebarFilterQueryStorageKey,readPersistedSidebarFilterQuery,- PopoverFilterBuilder,-} from "@/src/features/filters";+} from "@/src/features/filters/lib/persistedSidebarFilterQuery";+import { PopoverFilterBuilder } from "@/src/features/filters/components/filter-builder";import { StringParam, useQueryParam } from "use-query-params";@@ -121,10 +120,8 @@ import { SessionRedesignBanner } from "@/src/features/sessions/SessionRedesignBaimport { HeaderActionMenuRow } from "@/src/components/HeaderActionMenuRow";import { ModernSessionHeaderActionsController } from "@/src/features/sessions/ModernSessionHeaderActionsController";import { ConnectedSessionAddToDropdownMenuController } from "@/src/features/sessions/ConnectedSessionAddToDropdownMenuController";-import {- useInternalFeaturesEnabled,- useIsFeatureEnabled,-} from "@/src/features/feature-flags";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";+import { default as useIsFeatureEnabled } from "@/src/features/feature-flags/hooks/useIsFeatureEnabled";import { useIsMobile } from "@/src/hooks/use-mobile";import { useStore } from "zustand";import { TraceReviewPanelProvider } from "@/src/features/traces/contexts/TraceReviewPanelProvider";diff --git a/web/src/features/sessions/SessionRedesignBanner.tsx b/web/src/features/sessions/SessionRedesignBanner.tsxindex 1b732e86f7..092293cb31 100644--- a/web/src/features/sessions/SessionRedesignBanner.tsx+++ b/web/src/features/sessions/SessionRedesignBanner.tsx@@ -1,6 +1,6 @@import { ArrowUpRight, X } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export function SessionRedesignBanner({onDismiss,diff --git a/web/src/features/sessions/SessionReviewWorkspace.clienttest.tsx b/web/src/features/sessions/SessionReviewWorkspace.clienttest.tsxindex 10c4599fde..60c52e6f1b 100644--- a/web/src/features/sessions/SessionReviewWorkspace.clienttest.tsx+++ b/web/src/features/sessions/SessionReviewWorkspace.clienttest.tsx@@ -23,7 +23,9 @@ const { groupRef, router } = vi.hoisted(() => ({}));vi.mock("next/router", () => ({ useRouter: () => router }));-vi.mock("@/src/features/rbac", () => ({ useHasProjectAccess: () => true }));+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({+ useHasProjectAccess: () => true,+}));vi.mock("react-resizable-panels", async (importOriginal) => ({...(await importOriginal<typeof ResizablePanels>()),useGroupRef: () => groupRef,diff --git a/web/src/features/sessions/SessionTraceActionButtons.tsx b/web/src/features/sessions/SessionTraceActionButtons.tsxindex d37e985b22..7fc84bd63a 100644--- a/web/src/features/sessions/SessionTraceActionButtons.tsx+++ b/web/src/features/sessions/SessionTraceActionButtons.tsx@@ -3,8 +3,8 @@ import { api, type RouterOutputs } from "@/src/utils/api";import { getNumberFromMap } from "@/src/utils/map-utils";import { ActionButtonCountBadge } from "@/src/components/ui/ActionButtonCountBadge";import { Button } from "@/src/components/ui/button";-import { AnnotateDrawerController } from "@/src/features/scores";-import { CommentDrawerController } from "@/src/features/comments";+import { AnnotateDrawerController } from "@/src/features/scores/components/AnnotateDrawerController";+import { CommentDrawerController } from "@/src/features/comments/CommentDrawerController";import { ConnectedTraceObservationAddToDropdownMenuController } from "@/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController";import { cn } from "@/src/utils/tailwind";import {diff --git a/web/src/features/sessions/SessionsPage.tsx b/web/src/features/sessions/SessionsPage.tsxindex bf91b4d063..84755fe563 100644--- a/web/src/features/sessions/SessionsPage.tsx+++ b/web/src/features/sessions/SessionsPage.tsx@@ -4,7 +4,7 @@ import SessionsTable from "@/src/features/sessions/SessionsTable";import Page from "@/src/components/layouts/Page";import { SessionsOnboarding } from "@/src/components/onboarding/SessionsOnboarding";import { api } from "@/src/utils/api";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";export default function SessionsPage() {const router = useRouter();diff --git a/web/src/features/sessions/SessionsTable.tsx b/web/src/features/sessions/SessionsTable.tsxindex dd75904fcc..fb1cb8f659 100644--- a/web/src/features/sessions/SessionsTable.tsx+++ b/web/src/features/sessions/SessionsTable.tsx@@ -15,21 +15,23 @@ import { createNumberTableColumn } from "@/src/components/design-system/table/coimport { createTokenUsageTableColumn } from "@/src/components/design-system/table/columns/createTokenUsageTableColumn";import { StickySearchableTableFilterLayout } from "@/src/components/table/resizable-filter-layout";import { type LangfuseColumnDef } from "@/src/components/table/types";-import {- useColumnVisibility,- useColumnOrder,-} from "@/src/features/column-visibility";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";import {type UseSidebarFilterStateOptions,useSidebarFilterState,+} from "@/src/features/filters/hooks/useSidebarFilterState";++import {getSessionFilterConfig,SESSION_COLUMN_TO_BACKEND_KEY,type SessionOmittableFilterColumn,- buildSidebarFilterSessionContextId,- transformFiltersForBackend,- sortOptionValues,- sessionsFieldRegistry,-} from "@/src/features/filters";+} from "@/src/features/filters/config/sessions-config";++import { buildSidebarFilterSessionContextId } from "@/src/features/filters/lib/persistedSidebarFilterQuery";+import { transformFiltersForBackend } from "@/src/features/filters/lib/filter-transform";+import { sortOptionValues } from "@/src/features/filters/lib/option-sort";+import { sessionsFieldRegistry } from "@/src/features/filters/config/sessionsSearchRegistry";import {DEFAULT_SIDEBAR_IMPLICIT_ENVIRONMENT_CONFIG,@@ -43,9 +45,9 @@ import {type ScoreAggregate,} from "@langfuse/shared";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useEventsFilterOptions } from "@/src/features/events/hooks/useEventsFilterOptions";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { api } from "@/src/utils/api";import { formatIntervalSeconds } from "@/src/utils/dates";import { numberFormatter, usdFormatter } from "@/src/utils/numbers";@@ -57,7 +59,7 @@ import { useTableDateRange } from "@/src/hooks/useTableDateRange";import { tablePlaceholderOptions } from "@/src/components/table/utils/tablePlaceholder";import { toAbsoluteTimeRange } from "@/src/utils/date-range-utils";import { joinSessionCoreAndMetrics } from "@/src/features/sessions/session-row-data";-import { TagList } from "@/src/features/tag";+import { default as TagList } from "@/src/features/tag/components/TagList";import {customRowHeightMenu,isCompactRowHeight,@@ -68,21 +70,21 @@ import { TableHeaderControls } from "@/src/components/table/TableHeaderControls"import { cn } from "@/src/utils/tailwind";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";-import {- useSelectAll,- type TableAction,- TableActionMenu,- TableSelectionManager,-} from "@/src/features/table";+import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";+import type { TableAction } from "@/src/features/table/types";+import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";import { type RowSelectionState } from "@tanstack/react-table";-import { showSuccessToast } from "@/src/features/notifications";-import { useScoreColumns, scoreFilters } from "@/src/features/scores";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";+import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";-import { toObservedOptions, TableSearchBar } from "@/src/features/search-bar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export type SessionTableRow = {id: string;diff --git a/web/src/features/sessions/TraceEventsRow.tsx b/web/src/features/sessions/TraceEventsRow.tsxindex ef3066b902..34e6e1491c 100644--- a/web/src/features/sessions/TraceEventsRow.tsx+++ b/web/src/features/sessions/TraceEventsRow.tsx@@ -18,10 +18,10 @@ import {} from "@/src/features/sessions/sessionVisibleObservations";import {hasRenderableConversationMessages,- type IOPreviewContentMode,isOnlyJsonMessage,- useChatMLParser,-} from "@/src/features/traces";+} from "@/src/features/traces/fns/chatMessageUtils";+import type { IOPreviewContentMode } from "@/src/features/traces/components/IOPreview/IOPreview";+import { useChatMLParser } from "@/src/features/traces/hooks/useChatMLParser";export type TraceEventsSurface = "card" | "modern";diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart.tsxindex 54e2836b0f..ae2fe56838 100644--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart.tsx+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/components/SessionConversationTimeline/components/SessionConversationTimelineTrace/components/SessionTranscriptContent/components/SessionTimelinePart/SessionTimelinePart.tsx@@ -13,7 +13,7 @@ import {import { Button } from "@/src/components/ui/button";import { useState, type ComponentProps, type ReactNode } from "react";import { SessionTimelineCollapsibleRow } from "../SessionTimelineCollapsibleRow/SessionTimelineCollapsibleRow";-import { assertUnreachable } from "@langfuse/shared";+import { assertUnreachable, decodeUnicodeEscapesOnly } from "@langfuse/shared";import {type FilePart,type NormalizedMessage,@@ -30,7 +30,6 @@ import {} from "@/src/components/ui/media/mediaUtils";import { getSafeImageUrl, getSafeLinkUrl } from "@/src/components/ui/safe-url";import { cn } from "@/src/utils/tailwind";-import { decodeUnicodeEscapesOnly } from "@/src/utils/unicode";export function SessionTimelinePart({part,diff --git a/web/src/features/sessions/index.ts b/web/src/features/sessions/index.tsdeleted file mode 100644index ea159106b2..0000000000--- a/web/src/features/sessions/index.ts+++ /dev/null@@ -1,15 +0,0 @@-// The sessions feature's public surface (RFC rule 8). Named re-exports only —-// this is what anything outside the feature may use.-//-// Client-safe by construction: no server/ imports. SessionPage / SessionEventsPage-// are deliberately absent: a Next.js page imports its feature's Page component-// directly (same pattern as TracePage).--export { SessionIO } from "@/src/features/sessions/SessionPages";-export { LazyTraceEventsRow } from "@/src/features/sessions/TraceEventsRow";-export { asCommentCounts } from "@/src/features/sessions/sessionDetailPageTypes";-export {- SESSION_DETAIL_SYSTEM_PRESETS,- getSessionDetailPresetToApply,-} from "@/src/features/sessions/session-detail-presets";-export { default as SessionsTable } from "@/src/features/sessions/SessionsTable";diff --git a/web/src/features/sessions/sessionDetailPageTypes.ts b/web/src/features/sessions/sessionDetailPageTypes.tsindex 79060cb09c..3cc0877a77 100644--- a/web/src/features/sessions/sessionDetailPageTypes.ts+++ b/web/src/features/sessions/sessionDetailPageTypes.ts@@ -1,4 +1,4 @@-import { type ListEntry } from "@/src/features/navigate-detail-pages";+import type { ListEntry } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { type RouterOutputs } from "@/src/utils/api";import { type SingleValueOption } from "@langfuse/shared";diff --git a/web/src/features/sessions/useObservationCorrections.ts b/web/src/features/sessions/useObservationCorrections.tsindex 901e8aaa53..cbc23a2c67 100644--- a/web/src/features/sessions/useObservationCorrections.ts+++ b/web/src/features/sessions/useObservationCorrections.ts@@ -4,7 +4,7 @@ import {ScoreDataTypeEnum,type ScoreDomain,} from "@langfuse/shared";-import { getMostRecentCorrection } from "@/src/features/corrections";+import { getMostRecentCorrection } from "@/src/features/corrections/utils/getMostRecentCorrection";import { type SessionTraceObservation } from "./SessionObservationIO";import { api } from "@/src/utils/api";diff --git a/web/src/features/settings/SettingsPage.clienttest.tsx b/web/src/features/settings/SettingsPage.clienttest.tsxindex 0e25d259da..5ca6d3c243 100644--- a/web/src/features/settings/SettingsPage.clienttest.tsx+++ b/web/src/features/settings/SettingsPage.clienttest.tsx@@ -9,7 +9,7 @@ const router = vi.hoisted(() => ({vi.mock("next/router", () => ({ useRouter: () => router }));-vi.mock("@/src/features/account", () => ({+vi.mock("@/src/features/account/AccountSettingsPage", () => ({useAccountSettingsPages: () => [],}));diff --git a/web/src/features/settings/SettingsPage.tsx b/web/src/features/settings/SettingsPage.tsxindex 0a4587a701..1cd2cae399 100644--- a/web/src/features/settings/SettingsPage.tsx+++ b/web/src/features/settings/SettingsPage.tsx@@ -10,8 +10,8 @@ import { Badge } from "@/src/components/design-system/Badge/Badge";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";import { OrganizationDropdownMenu } from "@/src/components/OrganizationDropdownMenu/OrganizationDropdownMenu";import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";-import { useAccountSettingsPages } from "@/src/features/account";-import { useQueryOrganization } from "@/src/features/organizations";+import { useAccountSettingsPages } from "@/src/features/account/AccountSettingsPage";+import { useQueryOrganization } from "@/src/features/organizations/hooks";import { useOrganizationSettingsPages } from "@/src/features/organizations/OrganizationSettingsPage";import { accountSettingsPath } from "@/src/features/settings/accountSettingsPath";diff --git a/web/src/features/settings/index.ts b/web/src/features/settings/index.tsdeleted file mode 100644index 6aa1093899..0000000000--- a/web/src/features/settings/index.ts+++ /dev/null@@ -1 +0,0 @@-export { SettingsPage } from "@/src/features/settings/SettingsPage";diff --git a/web/src/features/setup/components/SetupPage.tsx b/web/src/features/setup/components/SetupPage.tsxindex a1a8ed3931..77cbbd999b 100644--- a/web/src/features/setup/components/SetupPage.tsx+++ b/web/src/features/setup/components/SetupPage.tsx@@ -10,7 +10,7 @@ import {import { Card } from "@/src/components/ui/card";import { ConnectedNewOrganizationForm } from "@/src/features/organizations/components/ConnectedNewOrganizationForm";import { NewProjectForm } from "@/src/features/projects/components/NewProjectForm";-import { useQueryProjectOrOrganization } from "@/src/features/projects";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";import { createProjectRoute } from "@/src/features/setup/setupRoutes";import { cn } from "@/src/utils/tailwind";import { Check } from "@langfuse/icons";diff --git a/web/src/features/setup/components/TracesSetupOnboardingCard.tsx b/web/src/features/setup/components/TracesSetupOnboardingCard.tsxindex 51f9ffb118..215be40017 100644--- a/web/src/features/setup/components/TracesSetupOnboardingCard.tsx+++ b/web/src/features/setup/components/TracesSetupOnboardingCard.tsx@@ -5,14 +5,14 @@ import { SplashScreen } from "@/src/components/ui/SplashScreen";import { copyTextToClipboard } from "@/src/utils/clipboard";import { ApiKeyDetailContent } from "@/src/features/public-api/components/ApiKeyDetailContent";import { useLangfuseBaseUrl } from "@/src/features/public-api/hooks/useLangfuseEnvCode";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api, reportNonTrpcError } from "@/src/utils/api";import { type RouterOutput } from "@/src/utils/types";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Check, Copy, LockIcon, Sparkles } from "@langfuse/icons";import Link from "next/link";import { useState } from "react";-import { showToast } from "@/src/features/notifications";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";const SKILLS_INSTALL_COMMAND =diff --git a/web/src/features/setup/index.ts b/web/src/features/setup/index.tsdeleted file mode 100644index e335ddd540..0000000000--- a/web/src/features/setup/index.ts+++ /dev/null@@ -1,8 +0,0 @@-// The setup feature's public surface (RFC rule 8). Named re-exports-// only — route helpers other features already imported by file path.-// This module is React-free, so server callers use the same door.-export {- createOrganizationRoute,- createProjectRoute,- setupTracingRoute,-} from "@/src/features/setup/setupRoutes";diff --git a/web/src/features/skills/components/ImportSkillsDialog.clienttest.tsx b/web/src/features/skills/components/ImportSkillsDialog.clienttest.tsxindex f6a209fdd3..657cd5cf1b 100644--- a/web/src/features/skills/components/ImportSkillsDialog.clienttest.tsx+++ b/web/src/features/skills/components/ImportSkillsDialog.clienttest.tsx@@ -15,7 +15,9 @@ const { discoverLocalSkills, byName, createVersion } = vi.hoisted(() => ({}));vi.mock("../utils/local-import", () => ({ discoverLocalSkills }));-vi.mock("@/src/features/notifications", () => ({ showSuccessToast: vi.fn() }));+vi.mock("@/src/features/notifications/showSuccessToast", () => ({+ showSuccessToast: vi.fn(),+}));vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));diff --git a/web/src/features/skills/components/ImportSkillsDialog.tsx b/web/src/features/skills/components/ImportSkillsDialog.tsxindex 67309d886f..cd2d289c54 100644--- a/web/src/features/skills/components/ImportSkillsDialog.tsx+++ b/web/src/features/skills/components/ImportSkillsDialog.tsx@@ -10,7 +10,7 @@ import { Dialog } from "@/src/components/design-system/Dialog/Dialog";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { Input } from "@/src/components/design-system/Input/Input";import { Tabs } from "@/src/components/design-system/Tabs/Tabs";-import { showSuccessToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api, getTrpcErrorCode, type RouterOutputs } from "@/src/utils/api";diff --git a/web/src/features/skills/components/SkillEditor.tsx b/web/src/features/skills/components/SkillEditor.tsxindex b011594d45..1e7a10c01d 100644--- a/web/src/features/skills/components/SkillEditor.tsx+++ b/web/src/features/skills/components/SkillEditor.tsx@@ -32,7 +32,8 @@ import { Dialog } from "@/src/components/design-system/Dialog/Dialog";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";import { Button as DesignSystemButton } from "@/src/components/design-system/Button/Button";import { InstallSkillDialog } from "@/src/features/skills/components/InstallSkillDialog";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { createSkillVersionFromDraft } from "@/src/features/skills/actions/createSkillVersion";import { downloadSkillVersion } from "@/src/features/skills/actions/downloadSkillVersion";@@ -66,7 +67,7 @@ import { SkillVersionHistory } from "@/src/features/skills/components/SkillVersiimport { SkillFileView } from "@/src/features/skills/components/SkillFileView";import { useSkillFileContents } from "@/src/features/skills/hooks/useSkillFileContents";import { useLangfuseV4WriteMode } from "@/src/features/organizations/hooks";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import {parseSkillFrontmatterMetadata,SKILL_NAME_RULES,diff --git a/web/src/features/skills/components/SkillEditorPage.tsx b/web/src/features/skills/components/SkillEditorPage.tsxindex 26cdd1cdf9..d33dcf915f 100644--- a/web/src/features/skills/components/SkillEditorPage.tsx+++ b/web/src/features/skills/components/SkillEditorPage.tsx@@ -4,7 +4,7 @@ import { useRouter } from "next/router";import { useStore } from "zustand";import Page from "@/src/components/layouts/Page";import { Skeleton } from "@/src/components/ui/skeleton";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { SKILL_LATEST_LABEL } from "@langfuse/shared";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {diff --git a/web/src/features/skills/components/SkillFileExplorer.tsx b/web/src/features/skills/components/SkillFileExplorer.tsxindex 79c5831121..06cf56f96c 100644--- a/web/src/features/skills/components/SkillFileExplorer.tsx+++ b/web/src/features/skills/components/SkillFileExplorer.tsx@@ -46,7 +46,7 @@ import {import { Button } from "@/src/components/ui/button";import { Input } from "@/src/components/ui/input";import { IconButton } from "@/src/components/design-system/IconButton/IconButton";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import {buildSkillFileTree,getParentFolderPaths,diff --git a/web/src/features/skills/components/SkillFileView.tsx b/web/src/features/skills/components/SkillFileView.tsxindex 4500c41f37..f72c9fcdb9 100644--- a/web/src/features/skills/components/SkillFileView.tsx+++ b/web/src/features/skills/components/SkillFileView.tsx@@ -1,7 +1,7 @@import { type ReactNode, useState } from "react";import { Badge } from "@/src/components/design-system/Badge/Badge";import { Tabs } from "@/src/components/design-system/Tabs/Tabs";-import { CodeMirrorEditor } from "@/src/components/editor";+import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { SkillFilePreview } from "./SkillFilePreview";import { getSkillFileLanguageExtensions } from "../utils/getSkillFileLanguageExtensions";diff --git a/web/src/features/skills/components/SkillsPage.tsx b/web/src/features/skills/components/SkillsPage.tsxindex 40f1e3b136..244659f78c 100644--- a/web/src/features/skills/components/SkillsPage.tsx+++ b/web/src/features/skills/components/SkillsPage.tsx@@ -21,7 +21,7 @@ import {withDefault,} from "use-query-params";import Page from "@/src/components/layouts/Page";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { Button } from "@/src/components/ui/button";import { Button as DesignSystemButton } from "@/src/components/design-system/Button/Button";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";@@ -44,12 +44,10 @@ import {} from "@/src/components/table/data-table-controls";import { FilterToggleButton } from "@/src/components/table/FilterToggleButton";import { ResizableFilterLayout } from "@/src/components/table/resizable-filter-layout";-import { useSidebarFilterState } from "@/src/features/filters";-import {- TableSearchBar,- toObservedOptions,- useFullTextSearch,-} from "@/src/features/search-bar";+import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFilterState";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";+import { useFullTextSearch } from "@/src/features/search-bar/hooks/useFullTextSearch";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { Badge } from "@/src/components/design-system/Badge/Badge";diff --git a/web/src/features/skills/server/index.ts b/web/src/features/skills/server/index.tsdeleted file mode 100644index eb1a635f34..0000000000--- a/web/src/features/skills/server/index.ts+++ /dev/null@@ -1 +0,0 @@-export { SkillService } from "./skill-service";diff --git a/web/src/features/skills/server/skill-router.ts b/web/src/features/skills/server/skill-router.tsindex 90971020e0..0e9ff02ea3 100644--- a/web/src/features/skills/server/skill-router.ts+++ b/web/src/features/skills/server/skill-router.ts@@ -13,8 +13,8 @@ import {createTRPCRouter,protectedProjectProcedure,} from "@/src/server/api/trpc";-import { throwIfNoProjectAccess } from "@/src/features/rbac";-import { SkillService } from "./index";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { SkillService } from "@/src/features/skills/server/skill-service";import { GetSkillFileContentsInputSchema } from "@/src/features/public-api/types/skills";import { SkillListOrderBySchema } from "../constants/skillsSorting";diff --git a/web/src/features/skills/server/skill-service.ts b/web/src/features/skills/server/skill-service.tsindex 8ad44bed51..47d1a38843 100644--- a/web/src/features/skills/server/skill-service.ts+++ b/web/src/features/skills/server/skill-service.ts@@ -32,8 +32,8 @@ import {} from "@langfuse/shared/src/server";import type { ProjectAuthedContext } from "@/src/server/api/trpc";import type { AuthorizationContext } from "@/src/features/auth/policy/types";-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { checkHasProtectedLabels } from "@/src/features/prompts/server/utils/checkHasProtectedLabels";import {authorizeProtectedLabelMutation,diff --git a/web/src/features/slack/SlackIntegrationPage.tsx b/web/src/features/slack/SlackIntegrationPage.tsxindex e8e3f63358..4472ae05db 100644--- a/web/src/features/slack/SlackIntegrationPage.tsx+++ b/web/src/features/slack/SlackIntegrationPage.tsx@@ -1,6 +1,6 @@import ContainerPage from "@/src/components/layouts/ContainerPage";import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";-import { AutomationButton } from "@/src/features/automations";+import { AutomationButton } from "@/src/features/automations/components/AutomationButton";import { SlackConnectionCard } from "@/src/features/slack/components/SlackConnectionCard";import {ChannelSelector,@@ -12,7 +12,7 @@ import { useSlackIntegration } from "@/src/features/slack/hooks/useSlackIntegratimport { useRouter } from "next/router";import { useState, useEffect } from "react";import { Badge } from "@/src/components/design-system/Badge/Badge";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {Card,CardContent,diff --git a/web/src/features/slack/components/SlackConnectionCard.tsx b/web/src/features/slack/components/SlackConnectionCard.tsxindex c6c2e0bd8b..deffacb963 100644--- a/web/src/features/slack/components/SlackConnectionCard.tsx+++ b/web/src/features/slack/components/SlackConnectionCard.tsx@@ -13,7 +13,7 @@ import { Alert } from "@/src/components/design-system/Alert/Alert";import { api } from "@/src/utils/api";import { SlackConnectButton } from "@/src/features/slack/components/SlackConnectButton";import { SlackDisconnectDialogController } from "@/src/features/slack/components/SlackDisconnectDialogController";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";/*** Props for the SlackConnectionCard componentdiff --git a/web/src/features/slack/components/SlackDisconnectDialogController.tsx b/web/src/features/slack/components/SlackDisconnectDialogController.tsxindex 737ae1ef17..4335dbcc11 100644--- a/web/src/features/slack/components/SlackDisconnectDialogController.tsx+++ b/web/src/features/slack/components/SlackDisconnectDialogController.tsx@@ -1,6 +1,7 @@import React from "react";import { DialogController } from "@/src/components/design-system/DialogController/DialogController";-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { api, reportTrpcErrorWithoutToast } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { SlackDisconnectDialog } from "@/src/features/slack/components/SlackDisconnectDialog/SlackDisconnectDialog";diff --git a/web/src/features/slack/hooks/useChannelSelectorData.ts b/web/src/features/slack/hooks/useChannelSelectorData.tsindex 2042afc6c6..6f57ab8bd3 100644--- a/web/src/features/slack/hooks/useChannelSelectorData.ts+++ b/web/src/features/slack/hooks/useChannelSelectorData.ts@@ -1,7 +1,7 @@import { useState } from "react";import { env } from "@/src/env.mjs";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useSlackChannels } from "@/src/features/slack/hooks/useSlackChannels";/** useChannelSelectorData loads the channel list and the refresh/reauthenticate actions ChannelSelectorView needs. */diff --git a/web/src/features/slack/hooks/useSlackConnect.ts b/web/src/features/slack/hooks/useSlackConnect.tsindex 682f1a8369..6ad78bbef0 100644--- a/web/src/features/slack/hooks/useSlackConnect.ts+++ b/web/src/features/slack/hooks/useSlackConnect.ts@@ -1,6 +1,7 @@import { useEffect, useRef, useState } from "react";-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { api } from "@/src/utils/api";/** useSlackConnect runs the Slack OAuth popup flow for a project and tracks whether it is pending or failed; it reports the outcome in a toast unless `shouldToast` is false. */diff --git a/web/src/features/slack/hooks/useSlackIntegration.ts b/web/src/features/slack/hooks/useSlackIntegration.tsindex da3e98738e..d5a15c26ba 100644--- a/web/src/features/slack/hooks/useSlackIntegration.ts+++ b/web/src/features/slack/hooks/useSlackIntegration.ts@@ -1,5 +1,5 @@import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";// A stored workspace that fails validation reads as inactive, same as nodiff --git a/web/src/features/slack/hooks/useSlackTestMessage.ts b/web/src/features/slack/hooks/useSlackTestMessage.tsindex 064aeb14c9..e10e32421d 100644--- a/web/src/features/slack/hooks/useSlackTestMessage.ts+++ b/web/src/features/slack/hooks/useSlackTestMessage.ts@@ -1,4 +1,5 @@-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { type SlackChannel } from "@/src/features/slack/components/ChannelSelector";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/slack/index.ts b/web/src/features/slack/index.tsdeleted file mode 100644index 1e5d5fa4b6..0000000000--- a/web/src/features/slack/index.ts+++ /dev/null@@ -1,16 +0,0 @@-// The slack feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export {- ChannelSelector,- type SlackChannel,-} from "@/src/features/slack/components/ChannelSelector";-export { SlackConnectionCard } from "@/src/features/slack/components/SlackConnectionCard";-export { SlackTestMessageButton } from "@/src/features/slack/components/SlackTestMessageButton";-export {- ChannelSelectorView,- type ChannelSelectorViewProps,-} from "@/src/features/slack/components/ChannelSelectorView/ChannelSelectorView";-export { useChannelSelectorData } from "@/src/features/slack/hooks/useChannelSelectorData";-export { useSlackConnect } from "@/src/features/slack/hooks/useSlackConnect";-export { useSlackTestMessage } from "@/src/features/slack/hooks/useSlackTestMessage";-export { type SlackTestMessageResult } from "@/src/features/slack/hooks/useSlackTestMessage";diff --git a/web/src/features/slack/server/index.ts b/web/src/features/slack/server/index.tsdeleted file mode 100644index 3d9fd79b80..0000000000--- a/web/src/features/slack/server/index.ts+++ /dev/null@@ -1,3 +0,0 @@-// The slack feature's server surface (RFC rule 9, amended): the webhook-// helper other server features already imported by file path.-export { sendToSlack } from "@/src/features/slack/server/slack-webhook";diff --git a/web/src/features/slack/server/oauth-handlers.ts b/web/src/features/slack/server/oauth-handlers.tsindex 1160c71712..61acc71805 100644--- a/web/src/features/slack/server/oauth-handlers.ts+++ b/web/src/features/slack/server/oauth-handlers.ts@@ -6,7 +6,7 @@ import {logger,} from "@langfuse/shared/src/server";import { getServerAuthSession } from "@/src/server/auth";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { prisma } from "@langfuse/shared/src/db";import { getSafeRedirectPath } from "@/src/utils/redirect";import { getProductBaseUrl } from "@/src/utils/base-url";diff --git a/web/src/features/slack/server/router.ts b/web/src/features/slack/server/router.tsindex ebf94e1bcb..545e1dcfc3 100644--- a/web/src/features/slack/server/router.ts+++ b/web/src/features/slack/server/router.ts@@ -11,9 +11,9 @@ import {getPrivateChannelViewerSlackUserId,logger,} from "@langfuse/shared/src/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { TRPCError } from "@trpc/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { env } from "@/src/env.mjs";import { getProductBaseUrl } from "@/src/utils/base-url";diff --git a/web/src/features/support-chat/ConnectedSupportFormSection.tsx b/web/src/features/support-chat/ConnectedSupportFormSection.tsxindex f2cb093f5f..914e7d9db5 100644--- a/web/src/features/support-chat/ConnectedSupportFormSection.tsx+++ b/web/src/features/support-chat/ConnectedSupportFormSection.tsx@@ -1,8 +1,8 @@"use client";import { api } from "@/src/utils/api";-import { useQueryProjectOrOrganization } from "@/src/features/projects";-import { showErrorToast } from "@/src/features/notifications";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { isEnterpriseSupportPlan } from "./formConstants";diff --git a/web/src/features/support-chat/IntroSection.tsx b/web/src/features/support-chat/IntroSection.tsxindex 16f6c44e53..653bacc4fb 100644--- a/web/src/features/support-chat/IntroSection.tsx+++ b/web/src/features/support-chat/IntroSection.tsx@@ -12,11 +12,11 @@ import {import { SiDiscord, SiGithub } from "@langfuse/icons/si";import { RainbowButton } from "@/src/components/magicui/RainbowButton";import { Separator } from "@/src/components/ui/separator";-import { usePlan } from "@/src/features/entitlements";+import { usePlan } from "@/src/features/entitlements/hooks";import { isCloudPlan } from "@langfuse/shared";-import { useUiCustomization } from "@/src/ee/features/ui-customization";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";type SupportType = "in-app-support" | "custom" | "community";diff --git a/web/src/features/support-chat/index.ts b/web/src/features/support-chat/index.tsdeleted file mode 100644index 5524ad4a74..0000000000--- a/web/src/features/support-chat/index.ts+++ /dev/null@@ -1,6 +0,0 @@-// The support-chat feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export {- SupportDrawerProvider,- useSupportDrawer,-} from "@/src/features/support-chat/SupportDrawerProvider";diff --git a/web/src/features/support-chat/trpc/supportRouter.ts b/web/src/features/support-chat/trpc/supportRouter.tsindex 1771945a29..5ebfdd5ab1 100644--- a/web/src/features/support-chat/trpc/supportRouter.ts+++ b/web/src/features/support-chat/trpc/supportRouter.ts@@ -6,7 +6,7 @@ import {import { TRPCError } from "@trpc/server";import { z } from "zod";import { env } from "@/src/env.mjs";-import { VERSION } from "@/src/constants";+import { VERSION } from "@/src/constants/VERSION";import { nanoid } from "nanoid";import { logger } from "@langfuse/shared/src/server";diff --git a/web/src/features/table/components/TableActionDialog.tsx b/web/src/features/table/components/TableActionDialog.tsxindex 4e240f5ca7..aa2a5618b6 100644--- a/web/src/features/table/components/TableActionDialog.tsx+++ b/web/src/features/table/components/TableActionDialog.tsx@@ -25,9 +25,9 @@ import {import { useForm } from "react-hook-form";import { type TableAction } from "@/src/features/table/types";import { TableActionTargetOptions } from "@/src/features/table/components/TableActionTargetOptions";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { ActionButton } from "@/src/components/ActionButton";-import { useOptionalEntitlement } from "@/src/features/entitlements";+import { useOptionalEntitlement } from "@/src/features/entitlements/hooks";import { type BatchExportTableName } from "@langfuse/shared";import { api } from "@/src/utils/api";import { targetOptionsQueryMap } from "@/src/features/table/components/targetOptionsQueryMap";diff --git a/web/src/features/table/components/TableActionTargetOptions.tsx b/web/src/features/table/components/TableActionTargetOptions.tsxindex f0eb3f6c06..e0aa494944 100644--- a/web/src/features/table/components/TableActionTargetOptions.tsx+++ b/web/src/features/table/components/TableActionTargetOptions.tsx@@ -1,5 +1,5 @@import { SelectItem } from "@/src/components/ui/select";-import { useOptionalEntitlement } from "@/src/features/entitlements";+import { useOptionalEntitlement } from "@/src/features/entitlements/hooks";import { targetOptionsQueryMap } from "@/src/features/table/components/targetOptionsQueryMap";import { type TableAction } from "@/src/features/table/types";import { useSession } from "next-auth/react";diff --git a/web/src/features/table/index.ts b/web/src/features/table/index.tsdeleted file mode 100644index 926e62145d..0000000000--- a/web/src/features/table/index.ts+++ /dev/null@@ -1,11 +0,0 @@-// The table feature's public client surface (RFC rule 8). Named re-exports-// only — exactly what other features already imported from this feature's-// client modules.-//-// `server/` is a separate door. tableRouter stays a direct import from the-// tRPC root, which is not a feature. createBatchActionJob lives on-// `server/index.ts` so this client barrel never reaches instrumentation.-export { TableActionMenu } from "@/src/features/table/components/TableActionMenu";-export { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";-export { useSelectAll } from "@/src/features/table/hooks/useSelectAll";-export type { TableAction } from "@/src/features/table/types";diff --git a/web/src/features/table/server/createBatchActionJob.ts b/web/src/features/table/server/createBatchActionJob.tsindex d2f30f707b..93e7079cc2 100644--- a/web/src/features/table/server/createBatchActionJob.ts+++ b/web/src/features/table/server/createBatchActionJob.ts@@ -1,4 +1,4 @@-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { generateBatchActionId } from "@/src/features/table/server/helpers";import {ActionId,@@ -15,7 +15,7 @@ import {QueueJobs,} from "@langfuse/shared/src/server";import { TRPCError } from "@trpc/server";-import { assertLegacyTracingIoSearchCanCreateBatchJob } from "@/src/features/traces/server";+import { assertLegacyTracingIoSearchCanCreateBatchJob } from "@/src/features/traces/server/legacyIoSearch";import { prisma } from "@langfuse/shared/src/db";type CreateBatchActionJob = {diff --git a/web/src/features/table/server/index.ts b/web/src/features/table/server/index.tsdeleted file mode 100644index a4a5a3111c..0000000000--- a/web/src/features/table/server/index.ts+++ /dev/null@@ -1,3 +0,0 @@-// The table feature's public server surface (RFC rules 8 and 10).-// tableRouter stays a direct import from the tRPC root, which is not a feature.-export { createBatchActionJob } from "@/src/features/table/server/createBatchActionJob";diff --git a/web/src/features/table/types.ts b/web/src/features/table/types.tsindex 35cfb8078d..8b0f8a4417 100644--- a/web/src/features/table/types.ts+++ b/web/src/features/table/types.ts@@ -1,4 +1,4 @@-import type { Entitlement } from "@/src/features/entitlements";+import type { Entitlement } from "@/src/features/entitlements/constants/entitlements";import {type ProjectScope,type BatchActionType,diff --git a/web/src/features/tag/components/TagCommandItem.tsx b/web/src/features/tag/components/TagCommandItem.tsxindex f9c0934a3f..8039fd3618 100644--- a/web/src/features/tag/components/TagCommandItem.tsx+++ b/web/src/features/tag/components/TagCommandItem.tsx@@ -1,6 +1,6 @@import { InputCommandItem } from "@/src/components/ui/input-command";import { Button } from "@/src/components/ui/button";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";type TagCommandItemProps = {diff --git a/web/src/features/tag/components/TagInput.tsx b/web/src/features/tag/components/TagInput.tsxindex aaf7a6e780..276c105abd 100644--- a/web/src/features/tag/components/TagInput.tsx+++ b/web/src/features/tag/components/TagInput.tsx@@ -4,7 +4,7 @@ import { cn } from "@/src/utils/tailwind";import { X } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";import { Command as CommandPrimitive } from "cmdk";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";type TagInputProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Inputdiff --git a/web/src/features/tag/components/TagManager.tsx b/web/src/features/tag/components/TagManager.tsxindex f17d40ea9a..3cee27e4e1 100644--- a/web/src/features/tag/components/TagManager.tsx+++ b/web/src/features/tag/components/TagManager.tsx@@ -11,7 +11,7 @@ import {} from "@/src/components/ui/popover";import { Command, CommandGroup, CommandItem, CommandList } from "cmdk";import { cn } from "@/src/utils/tailwind";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Label } from "@/src/components/ui/label";type TagManagerProps = {diff --git a/web/src/features/tag/components/TagPromptDetailsPopover.tsx b/web/src/features/tag/components/TagPromptDetailsPopover.tsxindex 23b7ec9991..4f65ffa5f9 100644--- a/web/src/features/tag/components/TagPromptDetailsPopover.tsx+++ b/web/src/features/tag/components/TagPromptDetailsPopover.tsx@@ -1,7 +1,7 @@/* eslint-disable @repo/no-style-props */import React, { useState } from "react";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { type RouterOutput } from "@/src/utils/types";import TagManager from "@/src/features/tag/components/TagManager";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";diff --git a/web/src/features/tag/components/TagPromptPopover.tsx b/web/src/features/tag/components/TagPromptPopover.tsxindex 4c1396a646..666c77f9b6 100644--- a/web/src/features/tag/components/TagPromptPopover.tsx+++ b/web/src/features/tag/components/TagPromptPopover.tsx@@ -1,7 +1,7 @@/* eslint-disable @repo/no-style-props */import React, { useState } from "react";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { type RouterOutput, type RouterInput } from "@/src/utils/types";import TagManager from "@/src/features/tag/components/TagManager";import { trpcErrorToast } from "@/src/utils/trpcErrorToast";diff --git a/web/src/features/tag/hooks/useTagManager.tsx b/web/src/features/tag/hooks/useTagManager.tsxindex cef53cc7fa..dcd1d4a764 100644--- a/web/src/features/tag/hooks/useTagManager.tsx+++ b/web/src/features/tag/hooks/useTagManager.tsx@@ -1,4 +1,4 @@-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useEffect, useState, useMemo } from "react";type UseTagManagerProps = {diff --git a/web/src/features/tag/index.ts b/web/src/features/tag/index.tsdeleted file mode 100644index a707eb7863..0000000000--- a/web/src/features/tag/index.ts+++ /dev/null@@ -1,7 +0,0 @@-// The tag feature's public client surface (RFC rule 8). Named re-exports-// only. TagList and TagManager are default exports in their own files;-// the door names them, so consumers import them by name.-export { default as TagList } from "@/src/features/tag/components/TagList";-export { default as TagManager } from "@/src/features/tag/components/TagManager";-export { TagPromptDetailsPopover } from "@/src/features/tag/components/TagPromptDetailsPopover";-export { TagPromptPopover } from "@/src/features/tag/components/TagPromptPopover";diff --git a/web/src/features/telemetry/index.ts b/web/src/features/telemetry/index.tsindex f1b7f1afc5..db4f77607d 100644--- a/web/src/features/telemetry/index.ts+++ b/web/src/features/telemetry/index.ts@@ -1,4 +1,4 @@-import { VERSION } from "@/src/constants";+import { VERSION } from "@/src/constants/VERSION";import { ServerPosthog } from "@/src/features/posthog-analytics/ServerPosthog";import { Prisma, prisma } from "@langfuse/shared/src/db";import { v4 as uuidv4 } from "uuid";@@ -12,10 +12,8 @@ import {logger,} from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";-import {- getSelfHostedInstancePlanServerSide,- hasEntitlementBasedOnPlan,-} from "@/src/features/entitlements/server";+import { getSelfHostedInstancePlanServerSide } from "@/src/features/entitlements/server/getPlan";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";// Interval between jobs in minutesconst JOB_INTERVAL_MINUTES = Prisma.raw("720"); // 12 hoursdiff --git a/web/src/features/theming/ThemeToggle.tsx b/web/src/features/theming/ThemeToggle.tsxindex 24abf2d319..298b928e35 100644--- a/web/src/features/theming/ThemeToggle.tsx+++ b/web/src/features/theming/ThemeToggle.tsx@@ -2,7 +2,7 @@ import * as React from "react";import { Monitor, Moon, Sun } from "@langfuse/icons";import { useTheme } from "next-themes";import { cn } from "@/src/utils/tailwind";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export function ThemeToggle() {const { theme, setTheme } = useTheme();diff --git a/web/src/features/top-banner/index.ts b/web/src/features/top-banner/index.tsdeleted file mode 100644index 955978f4fc..0000000000--- a/web/src/features/top-banner/index.ts+++ /dev/null@@ -1 +0,0 @@-export { useTopBannerHeight } from "./useTopBannerHeight";diff --git a/web/src/features/topics/EmbeddingMapView.stories.tsx b/web/src/features/topics/EmbeddingMapView.stories.tsxindex a295ea89c6..fd821856d6 100644--- a/web/src/features/topics/EmbeddingMapView.stories.tsx+++ b/web/src/features/topics/EmbeddingMapView.stories.tsx@@ -2,7 +2,7 @@ import { useState, type ComponentProps } from "react";import { expect, fn, userEvent, waitFor, within } from "storybook/test";import preview from "../../../.storybook/preview";import { Button } from "@/src/components/design-system/Button/Button";-import { EmbeddingMapView } from "./EmbeddingMapView";+import { TopicMapExplorer as EmbeddingMapView } from "@/src/features/topics/map/TopicMapExplorer";import {fitCamera,prepareTopicMap,diff --git a/web/src/features/topics/EmbeddingMapView.tsx b/web/src/features/topics/EmbeddingMapView.tsxdeleted file mode 100644index 63469448db..0000000000--- a/web/src/features/topics/EmbeddingMapView.tsx+++ /dev/null@@ -1,4 +0,0 @@-export {- TopicMapExplorer as EmbeddingMapView,- __test,-} from "./map/TopicMapExplorer";diff --git a/web/src/features/topics/TopicEmbeddingMap.tsx b/web/src/features/topics/TopicEmbeddingMap.tsxindex 39ddd611ce..75410196f2 100644--- a/web/src/features/topics/TopicEmbeddingMap.tsx+++ b/web/src/features/topics/TopicEmbeddingMap.tsx@@ -1,6 +1,6 @@import { Alert } from "@/src/components/design-system/Alert/Alert";import { type RouterOutputs } from "@/src/utils/api";-import { EmbeddingMapView } from "./EmbeddingMapView";+import { TopicMapExplorer as EmbeddingMapView } from "@/src/features/topics/map/TopicMapExplorer";import { TopicMapLoading } from "./TopicMapLoading";export function TopicEmbeddingMap({diff --git a/web/src/features/topics/TopicMapLoading.stories.tsx b/web/src/features/topics/TopicMapLoading.stories.tsxindex 1b02eb0712..f1ab61687c 100644--- a/web/src/features/topics/TopicMapLoading.stories.tsx+++ b/web/src/features/topics/TopicMapLoading.stories.tsx@@ -1,6 +1,6 @@import { expect, fn, waitFor, within } from "storybook/test";import preview from "../../../.storybook/preview";-import { EmbeddingMapView } from "./EmbeddingMapView";+import { TopicMapExplorer as EmbeddingMapView } from "@/src/features/topics/map/TopicMapExplorer";import { TopicMapLoading } from "./TopicMapLoading";const meta = preview.meta({diff --git a/web/src/features/topics/TopicSetupFlowController.tsx b/web/src/features/topics/TopicSetupFlowController.tsxindex f26a64b768..124e5477ba 100644--- a/web/src/features/topics/TopicSetupFlowController.tsx+++ b/web/src/features/topics/TopicSetupFlowController.tsx@@ -4,7 +4,7 @@ import { DialogController } from "@/src/components/design-system/DialogControlleimport { env } from "@/src/env.mjs";import { type JudgeModel } from "@/src/features/evals/v2/judgeModel";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { type ConfigureTopicsSettingsInput } from "./TopicModelSettings";import {diff --git a/web/src/features/topics/TopicTraceFilterSection.tsx b/web/src/features/topics/TopicTraceFilterSection.tsxindex 719ef83fd2..e01e7f69c1 100644--- a/web/src/features/topics/TopicTraceFilterSection.tsx+++ b/web/src/features/topics/TopicTraceFilterSection.tsx@@ -4,11 +4,9 @@ import { Input } from "@/src/components/design-system/Input/Input";import { ObservationFilterBuilder } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/ObservationFilterBuilder/ObservationFilterBuilder";import { FilterModeToggle } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/FilterModeToggle";import { RULE_FIELD_REGISTRY } from "@/src/features/evals/v2/constants/ruleSearchRegistry";-import {- EventsSearchBarRow,- type toObservedOptions,- useEventsSearchBar,-} from "@/src/features/search-bar";+import { EventsSearchBarRow } from "@/src/features/search-bar/components/EventsSearchBarRow";+import { type toObservedOptions } from "@/src/features/search-bar/lib/observed-options";+import { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";import type { EvaluatorFilterExperience } from "@/src/features/evals/v2/types/evaluatorFilterExperience";import {type experimentEvalFilterColsWithOptions,diff --git a/web/src/features/topics/TopicTraceSelector.clienttest.tsx b/web/src/features/topics/TopicTraceSelector.clienttest.tsxindex 0e3edc3d76..c6461c3163 100644--- a/web/src/features/topics/TopicTraceSelector.clienttest.tsx+++ b/web/src/features/topics/TopicTraceSelector.clienttest.tsx@@ -34,7 +34,17 @@ vi.mock("@/src/features/events/hooks/useEventsFilterOptions", () => ({isFilterOptionsPending: false,}),}));-vi.mock("@/src/features/search-bar", () => ({+vi.mock("@/src/features/search-bar/components/TableSearchBar", () => ({+ TableSearchBar: () => <div>Query editor</div>,+ toObservedOptions: () => ({}),+ fieldRegistryFromColumns: () => ({ fields: [], columns: [] }),+}));+vi.mock("@/src/features/search-bar/lib/observed-options", () => ({+ TableSearchBar: () => <div>Query editor</div>,+ toObservedOptions: () => ({}),+ fieldRegistryFromColumns: () => ({ fields: [], columns: [] }),+}));+vi.mock("@/src/features/search-bar/lib/fields", () => ({TableSearchBar: () => <div>Query editor</div>,toObservedOptions: () => ({}),fieldRegistryFromColumns: () => ({ fields: [], columns: [] }),diff --git a/web/src/features/topics/TopicTraceSelector.tsx b/web/src/features/topics/TopicTraceSelector.tsxindex 221fb0fdcc..41fdb9a747 100644--- a/web/src/features/topics/TopicTraceSelector.tsx+++ b/web/src/features/topics/TopicTraceSelector.tsx@@ -7,7 +7,7 @@ import {type TimeFilter,} from "@langfuse/shared";import { api, type RouterInputs } from "@/src/utils/api";-import { toObservedOptions } from "@/src/features/search-bar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { useEventsFilterOptions } from "@/src/features/events/hooks/useEventsFilterOptions";import {TopicTraceSelectorView,diff --git a/web/src/features/topics/TopicTraceSelectorView.tsx b/web/src/features/topics/TopicTraceSelectorView.tsxindex 97f1fa97f0..edcf41eee5 100644--- a/web/src/features/topics/TopicTraceSelectorView.tsx+++ b/web/src/features/topics/TopicTraceSelectorView.tsx@@ -14,7 +14,7 @@ import { Tabs } from "@/src/components/design-system/Tabs/Tabs";import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";import { Table } from "@/src/components/design-system/table/Table";import { PaginationBar } from "@/src/components/design-system/PaginationBar/PaginationBar";-import { TableSearchBar } from "@/src/features/search-bar";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";import { RULE_FIELD_REGISTRY } from "@/src/features/evals/v2/constants/ruleSearchRegistry";import { FilterModeToggle } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/FilterModeToggle";import { ObservationFilterBuilder } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/ObservationFilterBuilder/ObservationFilterBuilder";diff --git a/web/src/features/topics/TopicsTraceToolbar.tsx b/web/src/features/topics/TopicsTraceToolbar.tsxindex a0091a2394..50121efa45 100644--- a/web/src/features/topics/TopicsTraceToolbar.tsx+++ b/web/src/features/topics/TopicsTraceToolbar.tsx@@ -1,5 +1,5 @@import type { FilterState } from "@langfuse/shared";-import { TableSearchBar } from "@/src/features/search-bar";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";import {createTopicTraceRegistry,TOPIC_ASSIGNMENT_OPTIONS,diff --git a/web/src/features/topics/topic-map-geometry.clienttest.ts b/web/src/features/topics/topic-map-geometry.clienttest.tsindex 139a6452ae..adb4082c61 100644--- a/web/src/features/topics/topic-map-geometry.clienttest.ts+++ b/web/src/features/topics/topic-map-geometry.clienttest.ts@@ -1,5 +1,5 @@import { describe, expect, it } from "vitest";-import { __test } from "./EmbeddingMapView";+import { __test } from "@/src/features/topics/map/TopicMapExplorer";import {baseScale,fitCamera,diff --git a/web/src/features/trace-graph-view/index.ts b/web/src/features/trace-graph-view/index.tsdeleted file mode 100644index 059c115676..0000000000--- a/web/src/features/trace-graph-view/index.ts+++ /dev/null@@ -1,11 +0,0 @@-// The trace-graph-view feature's public client surface (RFC rule 8).-// Named re-exports only — exactly what other features already imported.-//-// AgentGraphDataSchema stays on server/index.ts so eventsRouter does-// not load TraceGraphView.-export { TraceGraphView } from "@/src/features/trace-graph-view/components/TraceGraphView";-export {- GRAPH_VIEW_MODES,- type AgentGraphDataResponse,- type GraphViewMode,-} from "@/src/features/trace-graph-view/types";diff --git a/web/src/features/trace-graph-view/server/index.ts b/web/src/features/trace-graph-view/server/index.tsdeleted file mode 100644index 810b207e43..0000000000--- a/web/src/features/trace-graph-view/server/index.ts+++ /dev/null@@ -1,6 +0,0 @@-// The trace-graph-view feature's server surface (RFC rule 9, amended):-// the graph payload schema tRPC routers already imported by file path.-export {- AgentGraphDataSchema,- type AgentGraphDataResponse,-} from "@/src/features/trace-graph-view/types";diff --git a/web/src/features/traces/TracePage.tsx b/web/src/features/traces/TracePage.tsxindex 8988490339..f91c0fd8e9 100644--- a/web/src/features/traces/TracePage.tsx+++ b/web/src/features/traces/TracePage.tsx@@ -1,4 +1,4 @@-import { DetailPageNav } from "@/src/features/navigate-detail-pages";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";import { useRouter } from "next/router";import { ErrorPage } from "@/src/components/error-page";import { TraceDetailActions } from "@/src/features/traces/components/TraceDetailActions";@@ -6,7 +6,7 @@ import { useTraceDetailData } from "@/src/features/traces/hooks/useTraceDetailDaimport Page from "@/src/components/layouts/Page";import { TraceDetailBody } from "@/src/features/traces/components/TraceDetailBody";import { useSession } from "next-auth/react";-import { useIsAuthenticatedAndProjectMember } from "@/src/features/auth";+import { useIsAuthenticatedAndProjectMember } from "@/src/features/auth/hooks";import { Button } from "@/src/components/ui/button";import Link from "next/link";import { stripBasePath } from "@/src/utils/redirect";diff --git a/web/src/features/traces/TracesPage.tsx b/web/src/features/traces/TracesPage.tsxindex 5f0ec56c56..1e540b4c37 100644--- a/web/src/features/traces/TracesPage.tsx+++ b/web/src/features/traces/TracesPage.tsx@@ -4,10 +4,13 @@ import TracesTable from "@/src/features/traces/TracesTable";import Page from "@/src/components/layouts/Page";import { api } from "@/src/utils/api";import { TracesOnboarding } from "@/src/components/onboarding/TracesOnboarding";-import { getTracingTabs, TRACING_TABS } from "@/src/features/navigation";-import { useReadPath } from "@/src/features/events";+import {+ getTracingTabs,+ TRACING_TABS,+} from "@/src/features/navigation/utils/tracing-tabs";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import ObservationsEventsTable from "@/src/features/events/components/EventsTable";-import { useQueryProject } from "@/src/features/projects";+import { useQueryProject } from "@/src/features/projects/hooks";import { V4MigrationDelayBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";export default function TracesPage() {diff --git a/web/src/features/traces/TracesSetupPage.tsx b/web/src/features/traces/TracesSetupPage.tsxindex ce7232e105..3e7760da14 100644--- a/web/src/features/traces/TracesSetupPage.tsx+++ b/web/src/features/traces/TracesSetupPage.tsx@@ -2,7 +2,7 @@import React, { useEffect, useState } from "react";import { useRouter } from "next/router";import { api, reportNonTrpcError } from "@/src/utils/api";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import ContainerPage from "@/src/components/layouts/ContainerPage";import { ActionButton } from "@/src/components/ActionButton";import { SubHeader } from "@/src/components/layouts/header";@@ -10,7 +10,7 @@ import { Button } from "@/src/components/ui/button";import { ApiKeyDetailContent } from "@/src/features/public-api/components/ApiKeyDetailContent";import { useLangfuseBaseUrl } from "@/src/features/public-api/hooks/useLangfuseEnvCode";import { type RouterOutput } from "@/src/utils/types";-import { useQueryProject } from "@/src/features/projects";+import { useQueryProject } from "@/src/features/projects/hooks";export const TracingSetup = ({projectId,diff --git a/web/src/features/traces/TracesTable.tsx b/web/src/features/traces/TracesTable.tsxindex 2bdc109d78..a8e1d33b42 100644--- a/web/src/features/traces/TracesTable.tsx+++ b/web/src/features/traces/TracesTable.tsx@@ -18,10 +18,8 @@ import { createTextTableColumn } from "@/src/components/design-system/table/coluimport { createTokenUsageTableColumn } from "@/src/components/design-system/table/columns/createTokenUsageTableColumn";import { SearchableTableFilterLayout } from "@/src/components/table/resizable-filter-layout";import { type LangfuseColumnDef } from "@/src/components/table/types";-import {- useColumnVisibility,- useColumnOrder,-} from "@/src/features/column-visibility";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";import { api } from "@/src/utils/api";import { formatIntervalSeconds } from "@/src/utils/dates";import { type RouterOutput } from "@/src/utils/types";@@ -42,8 +40,8 @@ import {import {detailPageListKeys,useDetailPageLists,-} from "@/src/features/navigate-detail-pages";-import { useOrderByState } from "@/src/features/orderBy";+} from "@/src/features/navigate-detail-pages/DetailPageListsProvider";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import {type FilterState,type ObservationLevelType,@@ -76,14 +74,12 @@ import { tablePlaceholderOptions } from "@/src/components/table/utils/tablePlaceimport { BatchExportTableButton } from "@/src/components/BatchExportTableButton";import { BreakdownTooltip } from "@/src/features/traces/components/BreakdownTooltip";import { InfoIcon, Trash2 } from "@langfuse/icons";-import { useHasEntitlement } from "@/src/features/entitlements";-import {- TableActionMenu,- useSelectAll,- TableSelectionManager,- type TableAction,-} from "@/src/features/table";-import { showSuccessToast } from "@/src/features/notifications";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";+import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";+import type { TableAction } from "@/src/features/table/types";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import {LevelCountsDisplay,type LevelCount,@@ -92,22 +88,24 @@ import { DropdownMenuItem } from "@/src/components/ui/dropdown-menu";import {type UseSidebarFilterStateOptions,useSidebarFilterState,+} from "@/src/features/filters/hooks/useSidebarFilterState";++import {getTraceFilterConfig,type TraceOmittableFilterColumn,- buildSidebarFilterSessionContextId,- sortOptionValues,- tracesFieldRegistry,-} from "@/src/features/filters";+} from "@/src/features/filters/config/traces-config";++import { buildSidebarFilterSessionContextId } from "@/src/features/filters/lib/persistedSidebarFilterQuery";+import { sortOptionValues } from "@/src/features/filters/lib/option-sort";+import { tracesFieldRegistry } from "@/src/features/filters/config/tracingSearchRegistry";import { TablePeekViewTraceDetail } from "@/src/components/table/peek/TablePeekViewTraceDetail";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";-import {- TableSearchBar,- toObservedOptions,- useFullTextSearch,-} from "@/src/features/search-bar";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";+import { useFullTextSearch } from "@/src/features/search-bar/hooks/useFullTextSearch";import { type TableDateRange } from "@/src/utils/date-range-utils";import useSessionStorage from "@/src/components/useSessionStorage";@@ -117,10 +115,11 @@ import {} from "@/src/components/table/utils/refresh-intervals";import { TableHeaderControls } from "@/src/components/table/TableHeaderControls";import { usePeekTableState } from "@/src/components/table/peek/contexts/PeekTableStateProvider";-import { useScoreColumns, scoreFilters } from "@/src/features/scores";-import { AddTracesToAnnotationQueueDialogController } from "@/src/features/annotation-queues";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";+import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";+import { AddTracesToAnnotationQueueDialogController } from "@/src/features/annotation-queues/components/AddTracesToAnnotationQueueDialogController";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";export type TracesTableRow = {diff --git a/web/src/features/traces/components/AdvancedJsonViewer/MultiSectionJsonViewer.tsx b/web/src/features/traces/components/AdvancedJsonViewer/MultiSectionJsonViewer.tsxindex 1364046ede..b48e8fb3b3 100644--- a/web/src/features/traces/components/AdvancedJsonViewer/MultiSectionJsonViewer.tsx+++ b/web/src/features/traces/components/AdvancedJsonViewer/MultiSectionJsonViewer.tsx@@ -26,7 +26,7 @@ import {} from "./SimpleMultiSectionViewer";import { SectionContextProvider } from "./contexts/SectionContextProvider";import { searchInTree, getMatchCountsPerNode } from "./utils/searchJson";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";import { type CommentedPathsByField } from "./utils/commentRanges";export interface MultiSectionJsonViewerHandle {diff --git a/web/src/features/traces/components/AdvancedJsonViewer/SimpleMultiSectionViewer.tsx b/web/src/features/traces/components/AdvancedJsonViewer/SimpleMultiSectionViewer.tsxindex c7f82ff554..345084aa4b 100644--- a/web/src/features/traces/components/AdvancedJsonViewer/SimpleMultiSectionViewer.tsx+++ b/web/src/features/traces/components/AdvancedJsonViewer/SimpleMultiSectionViewer.tsx@@ -29,7 +29,7 @@ import {type CommentedPathsByField,} from "./utils/commentRanges";import { pathArrayToJsonPath } from "./utils/pathUtils";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";export interface SimpleMultiSectionViewerHandle {scrollToSection: (sectionKey: string) => void;diff --git a/web/src/features/traces/components/AdvancedJsonViewer/VirtualizedMultiSectionViewer.tsx b/web/src/features/traces/components/AdvancedJsonViewer/VirtualizedMultiSectionViewer.tsxindex f0b05d1656..2c0d7ba087 100644--- a/web/src/features/traces/components/AdvancedJsonViewer/VirtualizedMultiSectionViewer.tsx+++ b/web/src/features/traces/components/AdvancedJsonViewer/VirtualizedMultiSectionViewer.tsx@@ -36,7 +36,7 @@ import {type CommentedPathsByField,} from "./utils/commentRanges";import { pathArrayToJsonPath } from "./utils/pathUtils";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";export interface VirtualizedMultiSectionViewerHandle {scrollToSection: (sectionKey: string) => void;diff --git a/web/src/features/traces/components/AdvancedJsonViewer/components/MediaButtonGroup.tsx b/web/src/features/traces/components/AdvancedJsonViewer/components/MediaButtonGroup.tsxindex dd20fd74ff..fd389387ea 100644--- a/web/src/features/traces/components/AdvancedJsonViewer/components/MediaButtonGroup.tsx+++ b/web/src/features/traces/components/AdvancedJsonViewer/components/MediaButtonGroup.tsx@@ -1,9 +1,7 @@/* eslint-disable @repo/no-null-render */import { useMemo, useState, useRef } from "react";-import {- mediaUrlQueryOptions,- type MediaReturnType,-} from "@/src/features/media";+import { mediaUrlQueryOptions } from "@/src/features/media/constants/mediaUrlQueryOptions";+import { type MediaReturnType } from "@/src/features/media/validation";import { File, Image as ImageIcon, Volume2, Video } from "@langfuse/icons";import { LangfuseMediaView } from "@/src/components/ui/LangfuseMediaView";import {diff --git a/web/src/features/traces/components/AdvancedJsonViewer/components/MultiSectionJsonViewerHeader.tsx b/web/src/features/traces/components/AdvancedJsonViewer/components/MultiSectionJsonViewerHeader.tsxindex 08f1028072..1f7e5f366e 100644--- a/web/src/features/traces/components/AdvancedJsonViewer/components/MultiSectionJsonViewerHeader.tsx+++ b/web/src/features/traces/components/AdvancedJsonViewer/components/MultiSectionJsonViewerHeader.tsx@@ -1,6 +1,6 @@import { ChevronRight, ChevronDown, MessageSquare } from "@langfuse/icons";import type { SectionContext } from "../types";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";import { MediaButtonGroup } from "./MediaButtonGroup";export interface MultiSectionJsonViewerHeaderProps {diff --git a/web/src/features/traces/components/AdvancedJsonViewer/lazy/react/LazyJsonViewer.tsx b/web/src/features/traces/components/AdvancedJsonViewer/lazy/react/LazyJsonViewer.tsxindex 7e39f4b22a..7973f51d25 100644--- a/web/src/features/traces/components/AdvancedJsonViewer/lazy/react/LazyJsonViewer.tsx+++ b/web/src/features/traces/components/AdvancedJsonViewer/lazy/react/LazyJsonViewer.tsx@@ -24,7 +24,7 @@ import { LazyJsonList } from "./LazyJsonList";import { createRowModelStore, type LazyViewerMetric } from "./rowModelStore";import { TreeRowModel } from "../treeRowModel";import { sourceFromSerialized } from "../asyncJsonSource";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { reportError } from "@/src/utils/reportError";// Provisional main-thread budgets (LFE-14419) — the telemetry exists to LEARNdiff --git a/web/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController.tsx b/web/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController.tsxindex 9af66f998a..a346e4d619 100644--- a/web/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController.tsx+++ b/web/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController.tsx@@ -6,15 +6,15 @@ import {DropdownMenu,type DropdownMenuItemDefinition,} from "@/src/components/design-system/DropdownMenu/DropdownMenu";-import { AnnotationQueueSubmenuItemController } from "@/src/features/annotation-queues";+import { AnnotationQueueSubmenuItemController } from "@/src/features/annotation-queues/components/AnnotationQueueSubmenuItemController";import { CreateDatasetDialogController } from "@/src/features/datasets/components/CreateDatasetDialogController";-import { NewDatasetItemFromExistingObjectDialogController } from "@/src/features/datasets";+import { NewDatasetItemFromExistingObjectDialogController } from "@/src/features/datasets/components/NewDatasetItemFromExistingObjectDialogController";import {type JumpToPlaygroundSourceProps,useJumpToPlayground,} from "@/src/features/playground/page/components/JumpToPlaygroundDropdownMenuController";-import { useHasProjectAccess } from "@/src/features/rbac";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type AnalyticsData } from "@/src/features/scores/types";import { api } from "@/src/utils/api";import type { MetadataDomainClient } from "@/src/utils/clientSideDomainTypes";diff --git a/web/src/features/traces/components/DeleteTraceDialogController.tsx b/web/src/features/traces/components/DeleteTraceDialogController.tsxindex c3fcd762d1..529521eaea 100644--- a/web/src/features/traces/components/DeleteTraceDialogController.tsx+++ b/web/src/features/traces/components/DeleteTraceDialogController.tsx@@ -2,10 +2,10 @@ import { useRouter } from "next/router";import { type ReactNode, useMemo, useState } from "react";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";-import { useHasEntitlement } from "@/src/features/entitlements";-import { showSuccessToast } from "@/src/features/notifications";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasEntitlement } from "@/src/features/entitlements/hooks";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";export function DeleteTraceDialogController({diff --git a/web/src/features/traces/components/DetailAttributesTab.clienttest.tsx b/web/src/features/traces/components/DetailAttributesTab.clienttest.tsxindex 07ba5f5b78..7b35c12b0a 100644--- a/web/src/features/traces/components/DetailAttributesTab.clienttest.tsx+++ b/web/src/features/traces/components/DetailAttributesTab.clienttest.tsx@@ -9,9 +9,12 @@ import { MediaEnabledFields } from "@/src/features/media/validation";vi.mock("@/src/components/ui/JsonViewController", () => ({JsonViewController: vi.fn(() => null),}));-vi.mock("@/src/features/feature-flags", () => ({- useInternalFeaturesEnabled: () => false,-}));+vi.mock(+ "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled",+ () => ({+ useInternalFeaturesEnabled: () => false,+ }),+);vi.mock("next/router", () => ({useRouter: () => ({asPath: "/project/project/traces",@@ -19,7 +22,7 @@ vi.mock("next/router", () => ({push: vi.fn(),}),}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));diff --git a/web/src/features/traces/components/DetailAttributesTab.tsx b/web/src/features/traces/components/DetailAttributesTab.tsxindex 0380bcfba7..8bc8cc44ac 100644--- a/web/src/features/traces/components/DetailAttributesTab.tsx+++ b/web/src/features/traces/components/DetailAttributesTab.tsx@@ -4,7 +4,7 @@ import { JsonViewController } from "@/src/components/ui/JsonViewController";import { FoldVertical, UnfoldVertical } from "@langfuse/icons";import { useMemo } from "react";import { useRouter } from "next/router";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";import { PrettyJsonViewContent } from "@/src/components/ui/PrettyJsonViewContent";import { IOSection } from "@/src/components/ui/IOSection";@@ -12,7 +12,7 @@ import { cn } from "@/src/utils/tailwind";import { IO_STICKY_HEADERS_CLASS } from "@/src/features/traces/constants/ioSectionClasses";import { getMetadataRowActions } from "@/src/features/traces/fns/getMetadataRowActions";import { getAttributeRowActions } from "@/src/features/traces/fns/getAttributeRowActions";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { LargeJsonFieldFallback } from "@/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback";import {JSON_VIEW_RENDER_CHAR_LIMIT,diff --git a/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx b/web/src/features/traces/components/DetailHeaderActionsMenuController.tsxindex f1f1e2ef10..25550e1c60 100644--- a/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx+++ b/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx@@ -10,11 +10,11 @@ import {import {buildEventsTablePathForObservationType,buildEventsTablePathForSpanName,-} from "@/src/features/events";+} from "@/src/features/events/lib/eventsTablePaths";import { copyTextToClipboard } from "@/src/utils/clipboard";import { type ObservationType } from "@langfuse/shared";-import { InternalFeatureBadge } from "@/src/features/feature-flags";-import { useWebCalloutAction } from "@/src/features/web-callouts";+import { InternalFeatureBadge } from "@/src/features/feature-flags/components/InternalFeatureBadge";+import { useWebCalloutAction } from "@/src/features/web-callouts/components/WebCalloutButton";type IdItem = {name: string;diff --git a/web/src/features/traces/components/IOPreview/IOPreview.tsx b/web/src/features/traces/components/IOPreview/IOPreview.tsxindex 1e27f4ca76..e8f52f99a6 100644--- a/web/src/features/traces/components/IOPreview/IOPreview.tsx+++ b/web/src/features/traces/components/IOPreview/IOPreview.tsx@@ -5,10 +5,10 @@ import {type ScoreDomain,type Prisma,} from "@langfuse/shared";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import useLocalStorage from "@/src/components/useLocalStorage";import { usePreserveRelativeScroll } from "@/src/features/traces/hooks/usePreserveRelativeScroll";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";import { type ExpansionState } from "@/src/features/traces/components/AdvancedJsonViewer/types";import { ViewModeToggle, type ViewMode } from "./components/ViewModeToggle";diff --git a/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx b/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsxindex cebef804e0..e7c4735ed7 100644--- a/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx+++ b/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx@@ -9,7 +9,7 @@ import { Command, CommandInput } from "@/src/components/ui/command";import { Button } from "@/src/components/ui/button";import { ChevronUp, ChevronDown, WrapText, Minus, Copy } from "@langfuse/icons";import { useJsonViewPreferences } from "@/src/features/traces/components/AdvancedJsonViewer/hooks/useJsonViewPreferences";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";import {InlineCommentSelectionProvider,diff --git a/web/src/features/traces/components/IOPreview/IOPreviewJSONSimple.tsx b/web/src/features/traces/components/IOPreview/IOPreviewJSONSimple.tsxindex 1b2c5db9c8..8ae15bd1ea 100644--- a/web/src/features/traces/components/IOPreview/IOPreviewJSONSimple.tsx+++ b/web/src/features/traces/components/IOPreview/IOPreviewJSONSimple.tsx@@ -2,7 +2,7 @@ import { JsonViewController } from "@/src/components/ui/JsonViewController";import { useMemo, useState } from "react";import { type Prisma, type ScoreDomain, deepParseJson } from "@langfuse/shared";import { PrettyJsonViewContent } from "@/src/components/ui/PrettyJsonViewContent";-import { type MediaReturnType } from "@/src/features/media";+import { type MediaReturnType } from "@/src/features/media/validation";import {CorrectedOutputField,useCorrectOutputAction,diff --git a/web/src/features/traces/components/IOPreview/IOPreviewPretty.stories.tsx b/web/src/features/traces/components/IOPreview/IOPreviewPretty.stories.tsxindex 5f395676a5..5e97fffc82 100644--- a/web/src/features/traces/components/IOPreview/IOPreviewPretty.stories.tsx+++ b/web/src/features/traces/components/IOPreview/IOPreviewPretty.stories.tsx@@ -15,9 +15,12 @@ import { observable } from "@trpc/server/observable";import type { AppRouter } from "@/src/server/api/root";import { api } from "@/src/utils/api";import { MarkdownRenderCharacterLimitContext } from "@/src/components/MarkdownRenderCharacterLimitProvider/MarkdownRenderCharacterLimitContext";-import { ChatMlMessageSchema } from "@/src/components/schemas/ChatMlSchema";-import { MediaContentType, type MediaReturnType } from "@/src/features/media";-import { MediaEnabledFields } from "@/src/features/media/validation";+import { ChatMlMessageSchema } from "@langfuse/shared";+import {+ MediaContentType,+ type MediaReturnType,+ MediaEnabledFields,+} from "@/src/features/media/validation";import { useCollapseSystemPromptPreference } from "@/src/hooks/useCollapsibleSystemPrompt";const TOOLS_COLLAPSED_KEY = "toolsSectionCollapsed";diff --git a/web/src/features/traces/components/IOPreview/IOPreviewPretty.tsx b/web/src/features/traces/components/IOPreview/IOPreviewPretty.tsxindex 0e1bf2b05a..2d9f0d6d88 100644--- a/web/src/features/traces/components/IOPreview/IOPreviewPretty.tsx+++ b/web/src/features/traces/components/IOPreview/IOPreviewPretty.tsx@@ -32,13 +32,13 @@ import {CollapsibleTrigger,} from "@/src/components/ui/collapsible";import { useMarkdownRenderCharacterLimit } from "@/src/hooks/useMarkdownRenderCharacterLimit";-import { type MediaReturnType } from "@/src/features/media";+import type { MediaReturnType } from "@/src/features/media/validation";import { type ChatMLParserResult } from "../../hooks/useChatMLParser";import {hasRenderableChatMessages,useIOPreviewParser,} from "../../hooks/useIOPreviewParser";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { ChatMessageController } from "./components/ChatMessageController";import { ChatMessageContent } from "./components/ChatMessageContent";import { SystemPromptCollapseController } from "./components/SystemPromptCollapseController";diff --git a/web/src/features/traces/components/IOPreview/components/CorrectedOutputField.clienttest.tsx b/web/src/features/traces/components/IOPreview/components/CorrectedOutputField.clienttest.tsxindex 93945ef4c8..0d02052cc9 100644--- a/web/src/features/traces/components/IOPreview/components/CorrectedOutputField.clienttest.tsx+++ b/web/src/features/traces/components/IOPreview/components/CorrectedOutputField.clienttest.tsx@@ -39,7 +39,7 @@ vi.mock("../hooks/useCorrectionEditor", () => ({},}));-vi.mock("@/src/features/rbac", () => ({+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({useHasProjectAccess: () => access.hasAccess,}));@@ -47,7 +47,7 @@ vi.mock("@/src/features/scores/hooks/useScoreEditsDisabled", () => ({useScoreEditsDisabled: () => access.scoreEditsDisabled,}));-vi.mock("@/src/features/posthog-analytics", () => ({+vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({usePostHogClientCapture: () => vi.fn(),}));diff --git a/web/src/features/traces/components/IOPreview/components/CorrectedOutputField.tsx b/web/src/features/traces/components/IOPreview/components/CorrectedOutputField.tsxindex 40c00a05e4..e82ea678e8 100644--- a/web/src/features/traces/components/IOPreview/components/CorrectedOutputField.tsx+++ b/web/src/features/traces/components/IOPreview/components/CorrectedOutputField.tsx@@ -13,9 +13,9 @@ import { useCorrectionEditor } from "../hooks/useCorrectionEditor";import { useCallback, useMemo, useRef, useState } from "react";import { type ReactCodeMirrorRef } from "@uiw/react-codemirror";import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useScoreEditsDisabled } from "@/src/features/scores/hooks/useScoreEditsDisabled";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import useLocalStorage from "@/src/components/useLocalStorage";import { CorrectedOutputDiffDialog } from "./CorrectedOutputDiffDialog";diff --git a/web/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback.tsx b/web/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback.tsxindex a10a9c841c..7c36911aad 100644--- a/web/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback.tsx+++ b/web/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback.tsx@@ -2,7 +2,7 @@ import { useMemo } from "react";import { Download } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";import { compactNumberFormatter } from "@/src/utils/numbers";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";/** How much of the raw payload the preview head shows. Bounded regardless of* payload size — the full value is reachable via download or the other views. */diff --git a/web/src/features/traces/components/IOPreview/hooks/useCorrectionData.ts b/web/src/features/traces/components/IOPreview/hooks/useCorrectionData.tsindex 7c2a35c4cb..013857008a 100644--- a/web/src/features/traces/components/IOPreview/hooks/useCorrectionData.ts+++ b/web/src/features/traces/components/IOPreview/hooks/useCorrectionData.ts@@ -1,5 +1,5 @@import { useMemo } from "react";-import { useCorrectionCacheOptional } from "@/src/features/corrections";+import { useCorrectionCacheOptional } from "@/src/features/corrections/contexts/CorrectionCacheProvider";import { type ScoreDomain } from "@langfuse/shared";/**diff --git a/web/src/features/traces/components/IOPreview/hooks/useCorrectionMutations.ts b/web/src/features/traces/components/IOPreview/hooks/useCorrectionMutations.tsindex 0dddfc4903..e890c7aeba 100644--- a/web/src/features/traces/components/IOPreview/hooks/useCorrectionMutations.ts+++ b/web/src/features/traces/components/IOPreview/hooks/useCorrectionMutations.ts@@ -1,9 +1,9 @@import { useState, useCallback } from "react";import { api } from "@/src/utils/api";-import { useCorrectionCache } from "@/src/features/corrections";+import { useCorrectionCache } from "@/src/features/corrections/contexts/CorrectionCacheProvider";import { type ScoreDomain } from "@langfuse/shared";import { v4 } from "uuid";-import { showToast } from "@/src/features/notifications";+import { showToast } from "@/src/features/notifications/showToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";interface UseCorrectionMutationsParams {diff --git a/web/src/features/traces/components/JSONTableView/index.ts b/web/src/features/traces/components/JSONTableView/index.tsdeleted file mode 100644index fe0b3095ed..0000000000--- a/web/src/features/traces/components/JSONTableView/index.ts+++ /dev/null@@ -1,21 +0,0 @@-/**- * JSONTableView - Generic virtualized table with customizable columns.- *- * @example- * ```tsx- * <JSONTableView- * items={data}- * getItemKey={(item) => item.id}- * columns={[- * { key: "name", header: "Name", width: "flex-1", render: (item) => item.name },- * { key: "value", header: "Value", width: "w-20", align: "right", render: (item) => item.value },- * ]}- * expandable- * renderExpanded={(item) => <ExpandedContent item={item} />}- * virtualized={data.length > 100}- * />- * ```- */--export { JSONTableView } from "./JSONTableView";-export type { JSONTableViewColumn } from "./json-table-view-types";diff --git a/web/src/features/traces/components/ObservationDetailView/ConnectedObservationDetailView.tsx b/web/src/features/traces/components/ObservationDetailView/ConnectedObservationDetailView.tsxindex 899c5a9e25..62ac801acd 100644--- a/web/src/features/traces/components/ObservationDetailView/ConnectedObservationDetailView.tsx+++ b/web/src/features/traces/components/ObservationDetailView/ConnectedObservationDetailView.tsx@@ -27,21 +27,21 @@ import { Tabs } from "@/src/components/design-system/Tabs/Tabs";import {CommentDrawerController,getCommentDrawerInitialStateFromUrl,- useCommentedPaths,-} from "@/src/features/comments";+} from "@/src/features/comments/CommentDrawerController";+import { useCommentedPaths } from "@/src/features/comments/hooks/useCommentedPaths";import { useRouter } from "next/router";import { TraceDetailTabsBarList } from "../TraceDetailTabsBarList";import { getDetailTabs } from "../../fns/getDetailTabs";import { resolveDetailTab } from "../../fns/resolveDetailTab";-import { ScoresTable } from "@/src/features/scores";-import { getMostRecentCorrection } from "@/src/features/corrections";+import { default as ScoresTable } from "@/src/features/scores/ScoresTable";+import { getMostRecentCorrection } from "@/src/features/corrections/utils/getMostRecentCorrection";import { useJsonExpansion } from "@/src/features/traces/contexts/JsonExpansionProvider";import { useMedia } from "@/src/features/traces/hooks/useMedia";import {type DetailTab,useSelection,} from "@/src/features/traces/contexts/SelectionProvider";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesProvider";import {@@ -57,17 +57,17 @@ import { api } from "@/src/utils/api";// Extracted componentsimport { ObservationDetailViewHeader } from "@/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader";import { TraceLogView } from "../TraceLogView/TraceLogView";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { TRACE_VIEW_CONFIG } from "@/src/features/traces/constants/traceViewConfig";import {aggregateTraceMetrics,getDescendantIds,} from "@/src/features/traces/fns/traceAggregation";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useSession } from "next-auth/react";import { ObservationPreview } from "./ObservationPreview";import type { IOPreviewPretty } from "../IOPreview/IOPreviewPretty";-import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";import { DetailAttributesTab } from "../DetailAttributesTab";import { buildModelParameters } from "@/src/features/traces/fns/buildModelParameters";import { buildObservationAttributes } from "@/src/features/traces/fns/buildObservationAttributes";diff --git a/web/src/features/traces/components/ObservationDetailView/components/ModelBadge.tsx b/web/src/features/traces/components/ObservationDetailView/components/ModelBadge.tsxindex 6257afaca5..ae0e199e6d 100644--- a/web/src/features/traces/components/ObservationDetailView/components/ModelBadge.tsx+++ b/web/src/features/traces/components/ObservationDetailView/components/ModelBadge.tsx@@ -5,7 +5,7 @@import { Badge } from "@/src/components/design-system/Badge/Badge";import { LinkBadge } from "@/src/components/design-system/LinkBadge/LinkBadge";-import { UpsertModelFormDialogController } from "@/src/features/models";+import { UpsertModelFormDialogController } from "@/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialogController";export function ModelBadge({model,diff --git a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsxindex fd565db0f2..599330dd53 100644--- a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx+++ b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx@@ -23,7 +23,7 @@ import {import { type ObservationReturnTypeWithMetadata } from "@/src/server/api/routers/traces";import { EntityTitle } from "@/src/components/EntityTitle";import { DetailViewHeaderShell } from "@/src/features/traces/components/DetailViewHeaderShell";-import { AnnotateDrawerController } from "@/src/features/scores";+import { AnnotateDrawerController } from "@/src/features/scores/components/AnnotateDrawerController";import { ConnectedTraceObservationAddToDropdownMenuController } from "@/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController";import { Badge } from "@/src/components/design-system/Badge/Badge";import { PromptBadge } from "@/src/features/traces/components/PromptBadge";@@ -48,7 +48,7 @@ import { type AggregatedTraceMetrics } from "@/src/features/traces/fns/traceAggrimport type Decimal from "decimal.js";import { ConnectedDetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesProvider";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { Button } from "@/src/components/ui/button";import { ActionButtonCountBadge } from "@/src/components/ui/ActionButtonCountBadge";import {diff --git a/web/src/features/traces/components/ToolCallInvocationsView.tsx b/web/src/features/traces/components/ToolCallInvocationsView.tsxindex 4d49ade91c..8a7b092cc6 100644--- a/web/src/features/traces/components/ToolCallInvocationsView.tsx+++ b/web/src/features/traces/components/ToolCallInvocationsView.tsx@@ -5,7 +5,7 @@ import { Wrench } from "@langfuse/icons";import { cn } from "@/src/utils/tailwind";import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";import type { z } from "zod";-import type { ChatMlMessageSchema } from "@/src/components/schemas/ChatMlSchema";+import type { ChatMlMessageSchema } from "@langfuse/shared";interface ToolCallInvocationsViewProps {message: z.infer<typeof ChatMlMessageSchema>;diff --git a/web/src/features/traces/components/Trace.tsx b/web/src/features/traces/components/Trace.tsxindex 161bde25eb..1b0b9343be 100644--- a/web/src/features/traces/components/Trace.tsx+++ b/web/src/features/traces/components/Trace.tsx@@ -36,13 +36,13 @@ import { useRouter } from "next/router";import { getCommentDrawerInitialStateFromUrl } from "@/src/features/comments/CommentDrawerController";import { TraceReviewPanelProvider } from "@/src/features/traces/contexts/TraceReviewPanelProvider";import { TraceReviewPanel } from "./TraceReviewPanel";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { staleProps } from "@/src/features/traces/fns/staleProps";import { cn } from "@/src/utils/tailwind";import { SkeletonGroup } from "@/src/components/ui/skeleton";import { Tabs } from "@/src/components/design-system/Tabs/Tabs";-import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";-import { useReadPath } from "@/src/features/events";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { StringParam, useQueryParam } from "use-query-params";import { TraceMessagesView } from "./TraceMessagesView/TraceMessagesView";diff --git a/web/src/features/traces/components/TraceDetailActions.tsx b/web/src/features/traces/components/TraceDetailActions.tsxindex 11557a451d..d5320f0196 100644--- a/web/src/features/traces/components/TraceDetailActions.tsx+++ b/web/src/features/traces/components/TraceDetailActions.tsx@@ -14,7 +14,7 @@ import {type DropdownMenuItemDefinition,} from "@/src/components/design-system/DropdownMenu/DropdownMenu";import { useShareMenuItems } from "@/src/components/useShareMenuItems";-import { InternalFeatureBadge } from "@/src/features/feature-flags";+import { InternalFeatureBadge } from "@/src/features/feature-flags/components/InternalFeatureBadge";import { ConnectedDetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";import { DeleteTraceDialogController } from "@/src/features/traces/components/DeleteTraceDialogController";import { TraceTranscriptDialogController } from "@/src/features/traces/components/TraceTranscriptDialogController";diff --git a/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx b/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsxindex 50a0e8bb07..7b67b84cb0 100644--- a/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx+++ b/web/src/features/traces/components/TraceDetailView/TraceDetailView.tsx@@ -14,8 +14,8 @@ import { IO_STICKY_HEADERS_CLASS } from "@/src/features/traces/constants/ioSectiimport {CommentDrawerController,getCommentDrawerInitialStateFromUrl,- useCommentedPaths,-} from "@/src/features/comments";+} from "@/src/features/comments/CommentDrawerController";+import { useCommentedPaths } from "@/src/features/comments/hooks/useCommentedPaths";import { api } from "@/src/utils/api";import { useRouter } from "next/router";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";@@ -38,20 +38,20 @@ import {type DetailTab,useSelection,} from "@/src/features/traces/contexts/SelectionProvider";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";-import { useIsAuthenticatedAndProjectMember } from "@/src/features/auth";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useIsAuthenticatedAndProjectMember } from "@/src/features/auth/hooks";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useSession } from "next-auth/react";// Extracted componentsimport { TraceDetailViewHeader } from "./components/TraceDetailViewHeader";import { TraceLogView } from "../TraceLogView/TraceLogView";import { TRACE_VIEW_CONFIG } from "@/src/features/traces/constants/traceViewConfig";-import { ScoresTable } from "@/src/features/scores";-import { getMostRecentCorrection } from "@/src/features/corrections";-import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";-import { useReadPath } from "@/src/features/events";+import { default as ScoresTable } from "@/src/features/scores/ScoresTable";+import { getMostRecentCorrection } from "@/src/features/corrections/utils/getMostRecentCorrection";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags/hooks/useInternalFeaturesEnabled";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { TraceDetailTabsBarList } from "../TraceDetailTabsBarList";import { DetailAttributesTab } from "../DetailAttributesTab";import { getDetailTabs } from "../../fns/getDetailTabs";diff --git a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsxindex b2e7f942d8..047d7f383a 100644--- a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx+++ b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx@@ -14,7 +14,7 @@ import { prepareTraceAnnotation } from "@/src/features/scores/lib/prepareTraceAnimport { headerActionClassName } from "@/src/features/traces/components/headerActionClassName";import { memo, useRef } from "react";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import {type TraceDomain,type ScoreDomain,@@ -27,7 +27,7 @@ import { Badge, BadgeShell } from "@/src/components/design-system/Badge/Badge";import { Skeleton } from "@/src/components/ui/skeleton";import { cn } from "@/src/utils/tailwind";import { ConnectedDetailHeaderActionsMenuController } from "@/src/features/traces/components/DetailHeaderActionsMenuController";-import { AnnotateDrawerController } from "@/src/features/scores";+import { AnnotateDrawerController } from "@/src/features/scores/components/AnnotateDrawerController";import { ActionButtonCountBadge } from "@/src/components/ui/ActionButtonCountBadge";import { ConnectedTraceObservationAddToDropdownMenuController } from "@/src/features/traces/components/ConnectedTraceObservationAddToDropdownMenuController";import {diff --git a/web/src/features/traces/components/TraceGraphView/TraceGraphView.tsx b/web/src/features/traces/components/TraceGraphView/TraceGraphView.tsxindex e05388a0ff..d2be725dfb 100644--- a/web/src/features/traces/components/TraceGraphView/TraceGraphView.tsx+++ b/web/src/features/traces/components/TraceGraphView/TraceGraphView.tsx@@ -7,13 +7,11 @@*/import { useCallback } from "react";-import {- TraceGraphView as TraceGraphViewComponent,- type GraphViewMode,-} from "@/src/features/trace-graph-view";+import { TraceGraphView as TraceGraphViewComponent } from "@/src/features/trace-graph-view/components/TraceGraphView";+import { type GraphViewMode } from "@/src/features/trace-graph-view/types";import { useTraceGraphData } from "@/src/features/traces/contexts/TraceGraphDataProvider";import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesProvider";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";import { useTraceSearchMatches } from "@/src/features/traces/hooks/useTraceSearchMatches";import { useSelection } from "../../contexts/SelectionProvider";diff --git a/web/src/features/traces/components/TraceHeader.tsx b/web/src/features/traces/components/TraceHeader.tsxindex 7a4358eaf3..8a04e3bbcf 100644--- a/web/src/features/traces/components/TraceHeader.tsx+++ b/web/src/features/traces/components/TraceHeader.tsx@@ -7,7 +7,7 @@ import { useMemo, useState, type ReactNode } from "react";import { GroupedScoreBadges } from "@/src/components/GroupedScoreBadges";import { BadgeShell } from "@/src/components/design-system/Badge/Badge";import { Skeleton } from "@/src/components/ui/skeleton";-import { TagList } from "@/src/features/tag";+import { default as TagList } from "@/src/features/tag/components/TagList";import {SessionBadge,UserIdBadge,diff --git a/web/src/features/traces/components/TraceLogView/TraceLogView.tsx b/web/src/features/traces/components/TraceLogView/TraceLogView.tsxindex 1f35df5c54..f6a9a643e6 100644--- a/web/src/features/traces/components/TraceLogView/TraceLogView.tsx+++ b/web/src/features/traces/components/TraceLogView/TraceLogView.tsx@@ -33,13 +33,13 @@import { useState, useMemo, useCallback } from "react";import { TRACE_VIEW_CONFIG } from "@/src/features/traces/constants/traceViewConfig";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";import { useTraceData } from "@/src/features/traces/contexts/TraceDataProvider";import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesProvider";import { type JsonViewPreference } from "@/src/components/ui/jsonViewPreference";import { useJsonExpansion } from "@/src/features/traces/contexts/JsonExpansionProvider";-import { JSONTableView } from "@/src/features/traces/components/JSONTableView";+import { JSONTableView } from "@/src/features/traces/components/JSONTableView/JSONTableView";import { type FlatLogItem } from "./log-view-types";import { LogViewToolbar } from "./LogViewToolbar";import { LogViewExpandedContent } from "./LogViewExpandedContent";diff --git a/web/src/features/traces/components/TraceLogView/useLogViewColumns.tsx b/web/src/features/traces/components/TraceLogView/useLogViewColumns.tsxindex 1a2aca3c00..7a353afa1c 100644--- a/web/src/features/traces/components/TraceLogView/useLogViewColumns.tsx+++ b/web/src/features/traces/components/TraceLogView/useLogViewColumns.tsx@@ -6,7 +6,7 @@*/import { useMemo } from "react";-import { type JSONTableViewColumn } from "@/src/features/traces/components/JSONTableView";+import type { JSONTableViewColumn } from "@/src/features/traces/components/JSONTableView/json-table-view-types";import { type FlatLogItem } from "./log-view-types";import { LogViewObservationCell } from "./LogViewObservationCell";import { formatRelativeTime, formatDuration } from "./log-view-formatters";diff --git a/web/src/features/traces/components/TraceLogView/useLogViewDownload.ts b/web/src/features/traces/components/TraceLogView/useLogViewDownload.tsindex 11f8a8c804..04aadb57f8 100644--- a/web/src/features/traces/components/TraceLogView/useLogViewDownload.ts+++ b/web/src/features/traces/components/TraceLogView/useLogViewDownload.ts@@ -9,7 +9,8 @@import { useState, useCallback } from "react";import { stringify } from "@langfuse/shared";import { copyTextToClipboard } from "@/src/utils/clipboard";-import { showSuccessToast, showToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showToast } from "@/src/features/notifications/showToast";import { type ObservationIOData } from "./useLogViewAllObservationsIO";export interface UseLogViewDownloadParams {diff --git a/web/src/features/traces/components/TraceLogView/useLogViewObservationIO.ts b/web/src/features/traces/components/TraceLogView/useLogViewObservationIO.tsindex f288644933..bfcb5a4cdf 100644--- a/web/src/features/traces/components/TraceLogView/useLogViewObservationIO.ts+++ b/web/src/features/traces/components/TraceLogView/useLogViewObservationIO.ts@@ -9,7 +9,7 @@ import { useMemo } from "react";import { useQueryClient } from "@tanstack/react-query";import { api, sendAsPostOption } from "@/src/utils/api";import { type FlatLogItem } from "./log-view-types";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";export interface UseLogViewObservationIOParams {observationId: string;diff --git a/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx b/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsxindex 1d36609a0c..94f4df7398 100644--- a/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx+++ b/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx@@ -50,7 +50,7 @@ import {} from "../TraceSettingsDropdown";import { TracePanelNavigationButton } from "./components/TracePanelNavigationButton";import { useDesktopLayoutContextOptional } from "../TraceLayoutDesktop";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";import { useElementSize } from "@/src/hooks/useElementSize";diff --git a/web/src/features/traces/components/TracePanelNavigationHeader/components/TracePanelNavigationButton.tsx b/web/src/features/traces/components/TracePanelNavigationHeader/components/TracePanelNavigationButton.tsxindex 4c516dd65e..2232daedf7 100644--- a/web/src/features/traces/components/TracePanelNavigationHeader/components/TracePanelNavigationButton.tsx+++ b/web/src/features/traces/components/TracePanelNavigationHeader/components/TracePanelNavigationButton.tsx@@ -1,7 +1,7 @@import { Button } from "@/src/components/ui/button";import { PanelLeftClose, PanelLeftOpen } from "@langfuse/icons";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";interface TracePanelNavigationButtonProps {diff --git a/web/src/features/traces/components/TraceReviewPanel.clienttest.tsx b/web/src/features/traces/components/TraceReviewPanel.clienttest.tsxindex 563e71d3c5..055479242d 100644--- a/web/src/features/traces/components/TraceReviewPanel.clienttest.tsx+++ b/web/src/features/traces/components/TraceReviewPanel.clienttest.tsx@@ -37,10 +37,12 @@ vi.mock("../contexts/TraceDataProvider", () => ({],}),}));-vi.mock("@/src/features/events", () => ({+vi.mock("@/src/features/events/hooks/useReadPath", () => ({useReadPath: () => ({ isV4: true }),}));-vi.mock("@/src/features/rbac", () => ({ useHasProjectAccess: () => true }));+vi.mock("@/src/features/rbac/utils/checkProjectAccess", () => ({+ useHasProjectAccess: () => true,+}));vi.mock("@/src/features/scores/components/AnnotationPanelContent", () => ({AnnotationPanelContent: ({data,diff --git a/web/src/features/traces/components/TraceReviewPanel.tsx b/web/src/features/traces/components/TraceReviewPanel.tsxindex 2c2bd1dda3..2092949db5 100644--- a/web/src/features/traces/components/TraceReviewPanel.tsx+++ b/web/src/features/traces/components/TraceReviewPanel.tsx@@ -2,10 +2,10 @@import { type AnnotationPanelData } from "@/src/features/scores/types";import { type CommentTarget } from "@/src/features/comments/state/commentOverlayStore";import { getCommentDrawerInitialStateFromUrl } from "@/src/features/comments/CommentDrawerController";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useTraceData } from "../contexts/TraceDataProvider";import { useSelection } from "../contexts/SelectionProvider";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { prepareTraceAnnotation } from "@/src/features/scores/lib/prepareTraceAnnotation";import { useStore } from "zustand";import { useEffect, useRef, type ReactNode } from "react";diff --git a/web/src/features/traces/components/TraceSearchList.tsx b/web/src/features/traces/components/TraceSearchList.tsxindex 5b5cd9dc7a..a53655bec9 100644--- a/web/src/features/traces/components/TraceSearchList.tsx+++ b/web/src/features/traces/components/TraceSearchList.tsx@@ -11,7 +11,7 @@ import { useTraceData } from "@/src/features/traces/contexts/TraceDataProvider";import { useSearch } from "@/src/features/traces/contexts/SearchProvider";import { useSelection } from "@/src/features/traces/contexts/SelectionProvider";import { useHandlePrefetchObservation } from "@/src/features/traces/hooks/useHandlePrefetchObservation";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";import { matchesSearchQuery } from "@/src/features/traces/fns/matchesSearchQuery";import { VirtualizedList } from "./VirtualizedList";diff --git a/web/src/features/traces/components/TraceSettingsDropdown.tsx b/web/src/features/traces/components/TraceSettingsDropdown.tsxindex 465c2f4006..fd461f87b7 100644--- a/web/src/features/traces/components/TraceSettingsDropdown.tsx+++ b/web/src/features/traces/components/TraceSettingsDropdown.tsx@@ -27,7 +27,7 @@ import {DropdownMenuLabel,} from "@/src/components/ui/dropdown-menu";import { Switch } from "@/src/components/design-system/Switch/Switch";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesProvider";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";diff --git a/web/src/features/traces/contexts/TraceDataProvider.tsx b/web/src/features/traces/contexts/TraceDataProvider.tsxindex 0e5377bc01..87792765ae 100644--- a/web/src/features/traces/contexts/TraceDataProvider.tsx+++ b/web/src/features/traces/contexts/TraceDataProvider.tsx@@ -29,7 +29,7 @@ import {} from "../fns/treeBuilding";import { type TraceMetricEmphasis } from "@/src/features/traces/fns/metricEmphasis";import { useViewPreferences } from "./ViewPreferencesProvider";-import { useMergedScores } from "@/src/features/scores";+import { useMergedScores } from "@/src/features/scores/lib/useMergedScores";import { traceLevelScoreOwnerIds } from "@/src/features/traces/fns/nodeScores";type TraceType = Omit<diff --git a/web/src/features/traces/contexts/TraceGraphDataProvider.tsx b/web/src/features/traces/contexts/TraceGraphDataProvider.tsxindex 9963cb30b3..97dd6b399b 100644--- a/web/src/features/traces/contexts/TraceGraphDataProvider.tsx+++ b/web/src/features/traces/contexts/TraceGraphDataProvider.tsx@@ -9,8 +9,8 @@import { createContext, useContext, useMemo, type ReactNode } from "react";import { api } from "@/src/utils/api";-import { type AgentGraphDataResponse } from "@/src/features/trace-graph-view";-import { useReadPath } from "@/src/features/events";+import type { AgentGraphDataResponse } from "@/src/features/trace-graph-view/types";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import {MAX_NODES_FOR_GRAPH_UI,resolveGraphAvailability,diff --git a/web/src/features/traces/contexts/ViewPreferencesProvider.tsx b/web/src/features/traces/contexts/ViewPreferencesProvider.tsxindex 315a31d41c..a30ae3ac95 100644--- a/web/src/features/traces/contexts/ViewPreferencesProvider.tsx+++ b/web/src/features/traces/contexts/ViewPreferencesProvider.tsx@@ -18,7 +18,8 @@ import { useCollapseSystemPromptPreference } from "@/src/hooks/useCollapsibleSysimport {GRAPH_VIEW_MODES,type GraphViewMode,-} from "@/src/features/trace-graph-view";+} from "@/src/features/trace-graph-view/types";+import {DEFAULT_JSON_VIEW_PREFERENCE,JSON_VIEW_PREFERENCE_STORAGE_KEY,diff --git a/web/src/features/traces/fns/chatMessageUtils.ts b/web/src/features/traces/fns/chatMessageUtils.tsindex fe139e5ce1..b65f4ebefc 100644--- a/web/src/features/traces/fns/chatMessageUtils.ts+++ b/web/src/features/traces/fns/chatMessageUtils.ts@@ -1,6 +1,9 @@import type { z } from "zod";-import type { ChatMlMessageSchema } from "@/src/components/schemas/ChatMlSchema";-import type { combineInputOutputMessages } from "@/src/utils/chatml";+import type {+ ChatMlMessageSchema,+ combineInputOutputMessages,+} from "@langfuse/shared";+import type { IOPreviewContentMode } from "@/src/features/traces/components/IOPreview/IOPreview";export type ChatMlMessage = z.infer<typeof ChatMlMessageSchema>;diff --git a/web/src/features/traces/fns/getAttributeRowActions.ts b/web/src/features/traces/fns/getAttributeRowActions.tsindex 627d239e97..9b67d7a6c3 100644--- a/web/src/features/traces/fns/getAttributeRowActions.ts+++ b/web/src/features/traces/fns/getAttributeRowActions.ts@@ -11,10 +11,10 @@ import { getCopyValue } from "@/src/components/table/ValueCell";import { type DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";import { type JsonTableRow } from "@/src/components/table/utils/jsonExpansionUtils";import { copyTextToClipboard } from "@/src/utils/clipboard";-import { buildEventsTablePathForColumnFilter } from "@/src/features/events";+import { buildEventsTablePathForColumnFilter } from "@/src/features/events/lib/eventsTablePaths";import { attributeColumnFilter } from "@/src/features/traces/fns/attributeColumnFilter";import { attributeGrammar } from "@/src/features/traces/fns/attributeGrammar";-import { type usePostHogClientCapture } from "@/src/features/posthog-analytics";+import type { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";export function getAttributeRowActions({row,diff --git a/web/src/features/traces/fns/getMetadataRowActions.ts b/web/src/features/traces/fns/getMetadataRowActions.tsindex 22891f9273..7de3019606 100644--- a/web/src/features/traces/fns/getMetadataRowActions.ts+++ b/web/src/features/traces/fns/getMetadataRowActions.ts@@ -9,7 +9,7 @@ import { copyTextToClipboard } from "@/src/utils/clipboard";import {buildEventsTablePathForMetadataFilter,type MetadataFilterOperator,-} from "@/src/features/events";+} from "@/src/features/events/lib/eventsTablePaths";/** Walks up to the top-level (level 0) ancestor key for a metadata row. */function resolveTopLevelMetadataKey(row: Row<JsonTableRow>): string {diff --git a/web/src/features/traces/fns/graphAvailability.clienttest.ts b/web/src/features/traces/fns/graphAvailability.clienttest.tsindex 809a855a50..4e46085989 100644--- a/web/src/features/traces/fns/graphAvailability.clienttest.ts+++ b/web/src/features/traces/fns/graphAvailability.clienttest.ts@@ -5,7 +5,7 @@ import {MAX_NODES_FOR_GRAPH_UI,resolveGraphAvailability,} from "./graphAvailability";-import { type AgentGraphDataResponse } from "@/src/features/trace-graph-view";+import type { AgentGraphDataResponse } from "@/src/features/trace-graph-view/types";const obs = (over: Partial<AgentGraphDataResponse> = {},diff --git a/web/src/features/traces/fns/graphAvailability.ts b/web/src/features/traces/fns/graphAvailability.tsindex 7727afee67..9eeb6d391a 100644--- a/web/src/features/traces/fns/graphAvailability.ts+++ b/web/src/features/traces/fns/graphAvailability.ts@@ -1,6 +1,6 @@/** Why the Graph view is or is not available for a trace. */-import { type AgentGraphDataResponse } from "@/src/features/trace-graph-view";+import type { AgentGraphDataResponse } from "@/src/features/trace-graph-view/types";export const MAX_NODES_FOR_GRAPH_UI = 5000;diff --git a/web/src/features/traces/hooks/useChatMLParser.ts b/web/src/features/traces/hooks/useChatMLParser.tsindex 551b2dd155..817b67b86c 100644--- a/web/src/features/traces/hooks/useChatMLParser.ts+++ b/web/src/features/traces/hooks/useChatMLParser.ts@@ -1,14 +1,15 @@import { useMemo } from "react";import type { z } from "zod";-import { type Prisma, deepParseJson } from "@langfuse/shared";import {+ type Prisma,+ deepParseJson,normalizeInput,normalizeOutput,combineInputOutputMessages,cleanLegacyOutput,extractAdditionalInput,-} from "@/src/utils/chatml";-import type { ChatMlMessageSchema } from "@/src/components/schemas/ChatMlSchema";+ type ChatMlMessageSchema,+} from "@langfuse/shared";// ChatML message type from schemaexport type ChatMlMessage = z.infer<typeof ChatMlMessageSchema>;diff --git a/web/src/features/traces/hooks/useDownloadTraceAsJson.ts b/web/src/features/traces/hooks/useDownloadTraceAsJson.tsindex 1e3dad1e4c..692855408e 100644--- a/web/src/features/traces/hooks/useDownloadTraceAsJson.ts+++ b/web/src/features/traces/hooks/useDownloadTraceAsJson.ts@@ -1,9 +1,9 @@import { useMemo } from "react";import { StringParam, useQueryParam } from "use-query-params";-import { useReadPath } from "@/src/features/events";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { showToast } from "@/src/features/notifications";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { showToast } from "@/src/features/notifications/showToast";import { TRACE_DOWNLOAD_OMIT_LARGE_FIELDS_THRESHOLD } from "@/src/features/traces/constants/traceDownloadConfig";import {downloadLegacyTraceAsJson,diff --git a/web/src/features/traces/hooks/useParsedObservation.ts b/web/src/features/traces/hooks/useParsedObservation.tsindex 6f55a8b2c3..b23dc7700c 100644--- a/web/src/features/traces/hooks/useParsedObservation.ts+++ b/web/src/features/traces/hooks/useParsedObservation.ts@@ -14,8 +14,8 @@import { useQuery } from "@tanstack/react-query";import { useMemo, useEffect } from "react";import { api, sendAsPostOption } from "@/src/utils/api";-import { useReadPath } from "@/src/features/events";-import type { EventBatchIOOutput } from "@/src/features/events/server";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import type { EventBatchIOOutput } from "@/src/features/events/server/eventsRouter";import {type ObservationReturnTypeWithMetadata,type ObservationReturnType,diff --git a/web/src/features/traces/hooks/usePrefetchObservation.ts b/web/src/features/traces/hooks/usePrefetchObservation.tsindex 6d1927f944..0ea6fb3abf 100644--- a/web/src/features/traces/hooks/usePrefetchObservation.ts+++ b/web/src/features/traces/hooks/usePrefetchObservation.ts@@ -1,5 +1,5 @@import { api, sendAsPostOption } from "@/src/utils/api";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";export type UsePrefetchObservationParams = {projectId: string;diff --git a/web/src/features/traces/hooks/useSelectTraceNode.ts b/web/src/features/traces/hooks/useSelectTraceNode.tsindex 22d4719ba4..7cae8e5265 100644--- a/web/src/features/traces/hooks/useSelectTraceNode.ts+++ b/web/src/features/traces/hooks/useSelectTraceNode.ts@@ -1,6 +1,6 @@import { useCallback } from "react";import { useSelection } from "@/src/features/traces/contexts/SelectionProvider";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";/** Which view is reporting the selection — the only thing that differs. */diff --git a/web/src/features/traces/hooks/useTraceAnalyticsDimensions.ts b/web/src/features/traces/hooks/useTraceAnalyticsDimensions.tsindex d44d29737e..5bc42292cb 100644--- a/web/src/features/traces/hooks/useTraceAnalyticsDimensions.ts+++ b/web/src/features/traces/hooks/useTraceAnalyticsDimensions.ts@@ -1,6 +1,6 @@import { useMemo } from "react";import { useViewPreferences } from "@/src/features/traces/contexts/ViewPreferencesProvider";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";/*** Shared segmentation dimensions for every `trace_detail:*` analytics event:diff --git a/web/src/features/traces/hooks/useTraceComments.ts b/web/src/features/traces/hooks/useTraceComments.tsindex f32c8ce201..840951d77b 100644--- a/web/src/features/traces/hooks/useTraceComments.ts+++ b/web/src/features/traces/hooks/useTraceComments.ts@@ -1,5 +1,5 @@import { api } from "@/src/utils/api";-import { useIsAuthenticatedAndProjectMember } from "@/src/features/auth";+import { useIsAuthenticatedAndProjectMember } from "@/src/features/auth/hooks";import { castToNumberMap } from "@/src/utils/map-utils";export type UseTraceCommentsParams = {diff --git a/web/src/features/traces/hooks/useTraceDetailData.ts b/web/src/features/traces/hooks/useTraceDetailData.tsindex 956972275d..4b1ffd7c9c 100644--- a/web/src/features/traces/hooks/useTraceDetailData.ts+++ b/web/src/features/traces/hooks/useTraceDetailData.ts@@ -1,6 +1,7 @@import { api, shouldRetryResourceQuery } from "@/src/utils/api";import { keepPreviousData } from "@tanstack/react-query";-import { useEventsTraceData, useReadPath } from "@/src/features/events";+import { useEventsTraceData } from "@/src/features/events/hooks/useEventsTraceData";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { useSession } from "next-auth/react";/**diff --git a/web/src/features/traces/index.ts b/web/src/features/traces/index.tsdeleted file mode 100644index 382f8bc8d2..0000000000--- a/web/src/features/traces/index.ts+++ /dev/null@@ -1,49 +0,0 @@-// The traces feature's public surface (RFC rule 8). Named re-exports only —-// this is the whole list of what anything outside the feature may use, and it-// starts as exactly what they already imported, nothing added for the future.-//-// Client-safe by construction: `server/` is deliberately absent, so importing-// this can never pull Prisma or ClickHouse into a browser bundle. The three-// server-side consumers of `server/legacyIoSearch` still import it directly —-// a full-stack feature needs a second, server-side surface, which the RFC does-// not have a rule for yet.--// TracePage is deliberately absent: a Next.js page imports its feature's Page-// component directly, which is what the RFC's own example does.-export { Trace } from "@/src/features/traces/components/Trace";-export { TraceDetailActions } from "@/src/features/traces/components/TraceDetailActions";-export { TraceDetailBody } from "@/src/features/traces/components/TraceDetailBody";-export { useTraceDetailData } from "@/src/features/traces/hooks/useTraceDetailData";--export { BreakdownTooltip } from "@/src/features/traces/components/BreakdownTooltip";-export { calculateAggregatedUsage } from "@/src/features/traces/fns/calculateAggregatedUsage";-export { CopyIdsPopover } from "@/src/features/traces/components/CopyIdsPopover";--export {- IOPreview,- type IOPreviewContentMode,- type ViewMode,-} from "@/src/features/traces/components/IOPreview/IOPreview";-export { ThinkingBlock } from "@/src/features/traces/components/ThinkingBlock";-export {- hasRenderableConversationMessages,- isOnlyJsonMessage,- shouldRenderMessageForContentMode,-} from "@/src/features/traces/fns/chatMessageUtils";-export {- useChatMLParser,- type ChatMLParserResult,-} from "@/src/features/traces/hooks/useChatMLParser";-// The session view resolves observation media the same way trace detail does,-// so a media-bearing message renders identically on both surfaces (LFE-14815).-export { useMedia } from "@/src/features/traces/hooks/useMedia";--// The JSON viewer's comment-range contract. It cannot be promoted to-// `src/fns` — it depends on the viewer's own path and row types — so the-// feature surface is where the comments feature reaches it.-export {- type CommentRange,- type CommentedPathsByField,-} from "@/src/features/traces/components/AdvancedJsonViewer/utils/commentRanges";--export { default as TracesTable } from "@/src/features/traces/TracesTable";diff --git a/web/src/features/traces/server/index.ts b/web/src/features/traces/server/index.tsdeleted file mode 100644index 2ed9a0c204..0000000000--- a/web/src/features/traces/server/index.ts+++ /dev/null@@ -1,6 +0,0 @@-// The traces feature's server surface (RFC rule 9, amended): the legacy-// IO-search guard batch jobs already imported by file path.-export {- assertLegacyTracingIoSearchCanCreateBatchJob,- sanitizeLegacyTracingSearch,-} from "@/src/features/traces/server/legacyIoSearch";diff --git a/web/src/features/tracing-tables/index.ts b/web/src/features/tracing-tables/index.tsdeleted file mode 100644index fb24b416b3..0000000000--- a/web/src/features/tracing-tables/index.ts+++ /dev/null@@ -1,4 +0,0 @@-// Tracing-tables front door — selection stores + legacy ObservationsTable.-// ObservationsPage is deliberately absent: the Next.js route imports it-// directly (same pattern as TracePage / SessionsPage).-export { default as ObservationsTable } from "@/src/features/tracing-tables/observations/ObservationsTable";diff --git a/web/src/features/tracing-tables/observations/ObservationsPage.tsx b/web/src/features/tracing-tables/observations/ObservationsPage.tsxindex 6c319fd3ff..5dbdcd67eb 100644--- a/web/src/features/tracing-tables/observations/ObservationsPage.tsx+++ b/web/src/features/tracing-tables/observations/ObservationsPage.tsx@@ -1,13 +1,16 @@/* eslint-disable no-nested-ternary */import { useRouter } from "next/router";-import { ObservationsTable } from "@/src/features/tracing-tables";+import { default as ObservationsTable } from "@/src/features/tracing-tables/observations/ObservationsTable";import Page from "@/src/components/layouts/Page";import { api } from "@/src/utils/api";import { TracesOnboarding } from "@/src/components/onboarding/TracesOnboarding";-import { getTracingTabs, TRACING_TABS } from "@/src/features/navigation";-import { useReadPath } from "@/src/features/events";+import {+ getTracingTabs,+ TRACING_TABS,+} from "@/src/features/navigation/utils/tracing-tabs";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import ObservationsEventsTable from "@/src/features/events/components/EventsTable";-import { useQueryProject } from "@/src/features/projects";+import { useQueryProject } from "@/src/features/projects/hooks";import { V4MigrationDelayBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";export default function ObservationsPage() {diff --git a/web/src/features/tracing-tables/observations/ObservationsTable.tsx b/web/src/features/tracing-tables/observations/ObservationsTable.tsxindex baf8535561..2b958b6b7a 100644--- a/web/src/features/tracing-tables/observations/ObservationsTable.tsx+++ b/web/src/features/tracing-tables/observations/ObservationsTable.tsx@@ -16,18 +16,22 @@ import {useRef,useCallback,} from "react";+import { useQueryFilterState } from "@/src/features/filters/hooks/useFilterState";import {- useQueryFilterState,type UseSidebarFilterStateOptions,useSidebarFilterState,+} from "@/src/features/filters/hooks/useSidebarFilterState";++import {getObservationsFilterConfig,OBSERVATION_COLUMN_TO_BACKEND_KEY,type ObservationsOmittableFilterColumn,- buildSidebarFilterSessionContextId,- transformFiltersForBackend,- sortOptionValues,- observationsFieldRegistry,-} from "@/src/features/filters";+} from "@/src/features/filters/config/observations-config";++import { buildSidebarFilterSessionContextId } from "@/src/features/filters/lib/persistedSidebarFilterQuery";+import { transformFiltersForBackend } from "@/src/features/filters/lib/filter-transform";+import { sortOptionValues } from "@/src/features/filters/lib/option-sort";+import { observationsFieldRegistry } from "@/src/features/filters/config/tracingSearchRegistry";import { usePaginationState } from "@/src/hooks/usePaginationState";import { useFacetOptionsWithObservedMetadata } from "@/src/hooks/useObservedMetadata";@@ -51,10 +55,8 @@ import {} from "@langfuse/shared";import { formatIntervalSeconds } from "@/src/utils/dates";-import {- useColumnVisibility,- useColumnOrder,-} from "@/src/features/column-visibility";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";import { Skeleton } from "@/src/components/ui/skeleton";import { type LangfuseColumnDef } from "@/src/components/table/types";import { ObservationLevelTag } from "@/src/components/ObservationLevelTag";@@ -63,7 +65,7 @@ import {formatObservationCost,isObservationCostDisplayable,} from "@/src/utils/observationCost";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import {customRowHeightMenu,isCompactRowHeight,@@ -80,13 +82,11 @@ import {} from "@/src/utils/date-range-utils";import { TableHeaderControls } from "@/src/components/table/TableHeaderControls";import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";-import { useHasProjectAccess } from "@/src/features/rbac";-import {- BreakdownTooltip,- calculateAggregatedUsage,-} from "@/src/features/traces";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { BreakdownTooltip } from "@/src/features/traces/components/BreakdownTooltip";+import { calculateAggregatedUsage } from "@/src/features/traces/fns/calculateAggregatedUsage";import { InfoIcon } from "@langfuse/icons";-import { ProvidedModelNameCell } from "@/src/features/models";+import { ProvidedModelNameCell } from "@/src/features/models/components/ProvidedModelNameCell";import { createTagTableColumn } from "@/src/components/design-system/table/columns/createTagTableColumn";import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";@@ -102,26 +102,23 @@ import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNaviimport {detailPageListKeys,useDetailPageLists,-} from "@/src/features/navigate-detail-pages";+} from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";-import {- TableSearchBar,- toObservedOptions,- useFullTextSearch,-} from "@/src/features/search-bar";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";+import { useFullTextSearch } from "@/src/features/search-bar/hooks/useFullTextSearch";import { useRouter } from "next/router";-import {- TableSelectionManager,- TableActionMenu,- type TableAction,-} from "@/src/features/table";-import { showSuccessToast } from "@/src/features/notifications";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";+import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";+import type { TableAction } from "@/src/features/table/types";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type DataTablePeekViewProps } from "@/src/components/table/peek";-import { useScoreColumns, scoreFilters } from "@/src/features/scores";-import { AddObservationsToDatasetDialog } from "@/src/features/batch-actions";+import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";+import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";+import { AddObservationsToDatasetDialog } from "@/src/features/batch-actions/components/AddObservationsToDatasetDialog/AddObservationsToDatasetDialog";import useSessionStorage from "@/src/components/useSessionStorage";import { getSafeRedirectPath } from "@/src/utils/redirect";import {diff --git a/web/src/features/tracing-tables/observations/useObservationsTableView.ts b/web/src/features/tracing-tables/observations/useObservationsTableView.tsindex 04b6b50673..520bccf5d7 100644--- a/web/src/features/tracing-tables/observations/useObservationsTableView.ts+++ b/web/src/features/tracing-tables/observations/useObservationsTableView.ts@@ -1,5 +1,5 @@import { useLayoutEffect, useState } from "react";-import { useSelectAll } from "@/src/features/table";+import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";import {createObservationsTableStore,type ObservationsTableStore,diff --git a/web/src/features/users/UserDetailPage.tsx b/web/src/features/users/UserDetailPage.tsxindex d674ce50e0..ac49e87b2d 100644--- a/web/src/features/users/UserDetailPage.tsx+++ b/web/src/features/users/UserDetailPage.tsx@@ -3,20 +3,20 @@ import { useRouter } from "next/router";import { api } from "@/src/utils/api";import { RouteParamsPendingFallback } from "@/src/components/RouteParamsPendingFallback/RouteParamsPendingFallback";import { useReadyRouteParams } from "@/src/hooks/useReadyRouteParams";-import { TracesTable } from "@/src/features/traces";-import { ScoresTable } from "@/src/features/scores";+import { default as TracesTable } from "@/src/features/traces/TracesTable";+import { default as ScoresTable } from "@/src/features/scores/ScoresTable";import { TablePeekViewTraceDetail } from "@/src/components/table/peek/TablePeekViewTraceDetail";import { compactNumberFormatter, usdFormatter } from "@/src/utils/numbers";import { StringParam, useQueryParam, withDefault } from "use-query-params";-import { DetailPageNav } from "@/src/features/navigate-detail-pages";-import { SessionsTable } from "@/src/features/sessions";+import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";+import { default as SessionsTable } from "@/src/features/sessions/SessionsTable";import { cn } from "@/src/utils/tailwind";import { Badge } from "@/src/components/design-system/Badge/Badge";import { ActionButton } from "@/src/components/ActionButton";import { LayoutDashboard } from "@langfuse/icons";import Page from "@/src/components/layouts/Page";-import { useReadPath } from "@/src/features/events";-import { ObservationsEventsTable } from "@/src/features/events/components";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { default as ObservationsEventsTable } from "@/src/features/events/components/EventsTable";const tabs = ["Traces", "Sessions", "Scores"] as const;diff --git a/web/src/features/users/UsersPage.tsx b/web/src/features/users/UsersPage.tsxindex 509abd29b0..60ed2b286a 100644--- a/web/src/features/users/UsersPage.tsx+++ b/web/src/features/users/UsersPage.tsx@@ -1,7 +1,7 @@import { useRouter } from "next/router";import Page from "@/src/components/layouts/Page";import { UsersOnboarding } from "@/src/components/onboarding/UsersOnboarding";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { api } from "@/src/utils/api";import { UsersTable } from "@/src/features/users/UsersTable";diff --git a/web/src/features/users/UsersTable.tsx b/web/src/features/users/UsersTable.tsxindex 3731459596..cc9c199a58 100644--- a/web/src/features/users/UsersTable.tsx+++ b/web/src/features/users/UsersTable.tsx@@ -23,24 +23,26 @@ import { getUsersFilterConfig } from "@/src/features/filters/config/users-configimport {USERS_FIELD_REGISTRY,LEGACY_USERS_FIELD_REGISTRY,+} from "@/src/features/filters/config/usersSearchRegistry";+import {useSidebarFilterPresentation,useSidebarFilterStateCore,type FacetOptions,type UseSidebarFilterStateOptions,- buildSidebarFilterSessionContextId,- sortOptionValues,-} from "@/src/features/filters";+} from "@/src/features/filters/hooks/useSidebarFilterState";++import { buildSidebarFilterSessionContextId } from "@/src/features/filters/lib/persistedSidebarFilterQuery";+import { sortOptionValues } from "@/src/features/filters/lib/option-sort";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";-import { useEventsFilterOptions } from "@/src/features/events";-import { TableSearchBar, toObservedOptions } from "@/src/features/search-bar";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";+import { useEventsFilterOptions } from "@/src/features/events/hooks/useEventsFilterOptions";+import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";-import {- useColumnOrder,- useColumnVisibility,-} from "@/src/features/column-visibility";+import { default as useColumnOrder } from "@/src/features/column-visibility/hooks/useColumnOrder";+import { default as useColumnVisibility } from "@/src/features/column-visibility/hooks/useColumnVisibility";import { api } from "@/src/utils/api";import { compactNumberFormatter, usdFormatter } from "@/src/utils/numbers";import { type RouterOutput } from "@/src/utils/types";diff --git a/web/src/features/v4-migration/EvaluatorMigrationDialog.tsx b/web/src/features/v4-migration/EvaluatorMigrationDialog.tsxindex 3ab9c0cc3b..d3058a99c6 100644--- a/web/src/features/v4-migration/EvaluatorMigrationDialog.tsx+++ b/web/src/features/v4-migration/EvaluatorMigrationDialog.tsx@@ -14,10 +14,10 @@ import { Codeblock as CodeBlock } from "@/src/components/design-system/Codeblockimport {useIsInAppAgentLauncherVisible,useInAppAiAgent,-} from "@/src/features/in-app-agent";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useQueryProjectOrOrganization } from "@/src/features/projects";-import { useHasOrganizationAccess } from "@/src/features/rbac";+} from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";type EvaluatorMigrationScope = { type: "all" } | { type: "single" };diff --git a/web/src/features/v4-migration/LegacyUiBanner.tsx b/web/src/features/v4-migration/LegacyUiBanner.tsxindex f4450e6857..d1fdf3692b 100644--- a/web/src/features/v4-migration/LegacyUiBanner.tsx+++ b/web/src/features/v4-migration/LegacyUiBanner.tsx@@ -1,7 +1,7 @@import { V4IntroDialog } from "@/src/features/events/components/V4IntroDialog";import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { useV4PreviewToggle } from "@/src/features/events/hooks/useV4PreviewToggle";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { LegacyUiBannerView } from "@/src/features/v4-migration/LegacyUiBannerView";import { useIsForceV3ExperienceSettled } from "@/src/features/v4-migration/useForceV3Experience";import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";diff --git a/web/src/features/v4-migration/V4MigrationBanner.tsx b/web/src/features/v4-migration/V4MigrationBanner.tsxindex ed5a0e994e..d664ed6674 100644--- a/web/src/features/v4-migration/V4MigrationBanner.tsx+++ b/web/src/features/v4-migration/V4MigrationBanner.tsx@@ -4,7 +4,7 @@ import { Zap } from "@langfuse/icons";import { Callout } from "@/src/components/design-system/Callout/Callout";import { DismissController } from "@/src/components/DismissController";import { useDismissState } from "@/src/hooks/useDismissState";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useAccountV4MigrationData } from "@/src/features/v4-migration/hooks/useV4MigrationData";import { getProjectMigrationReadiness } from "@/src/features/v4-migration/migrationData";import { env } from "@/src/env.mjs";diff --git a/web/src/features/v4-migration/V4MigrationContent.tsx b/web/src/features/v4-migration/V4MigrationContent.tsxindex 567c3af725..1829fe3b7b 100644--- a/web/src/features/v4-migration/V4MigrationContent.tsx+++ b/web/src/features/v4-migration/V4MigrationContent.tsx@@ -1,6 +1,7 @@/* eslint-disable no-nested-ternary, @repo/component-file-structure, react/no-unstable-nested-components *//* eslint-disable @repo/no-style-props, @repo/no-null-render */-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { type ReactNode, useEffect, useRef, useState } from "react";import { useRouter } from "next/router";import Link from "next/link";@@ -12,9 +13,9 @@ import {Info,} from "@langfuse/icons";import { env } from "@/src/env.mjs";-import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { useSupportDrawer } from "@/src/features/support-chat";+import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";import { Button } from "@/src/components/ui/button";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";import { RainbowButton } from "@/src/components/magicui/RainbowButton";@@ -24,7 +25,7 @@ import {CollapsibleContent,CollapsibleTrigger,} from "@/src/components/ui/collapsible";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { cn } from "@/src/utils/tailwind";import { copyTextToClipboard } from "@/src/utils/clipboard";import {@@ -48,15 +49,16 @@ import {type MigrationCountState,type ProjectMigrationReadiness,} from "@/src/features/v4-migration/migrationData";-import { useReadPath, V4PreviewToggleRow } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { V4PreviewToggleRow } from "@/src/features/events/components/V4SidebarToggle";import { numberFormatter } from "@/src/utils/numbers";import { formatCompactRelativeTime } from "@/src/utils/dates";-import { useQueryProjectOrOrganization } from "@/src/features/projects";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";import {useEvalUpgradeAssistantPlan,V4_CODING_AGENT_PROMPT,} from "@/src/features/v4-migration/useV4UpgradeAssistantSupport";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { encodeFiltersGeneric, type FilterState } from "@langfuse/shared";diff --git a/web/src/features/v4-migration/V4MigrationDelayBadge.tsx b/web/src/features/v4-migration/V4MigrationDelayBadge.tsxindex 421239f1c7..8a58f2fb11 100644--- a/web/src/features/v4-migration/V4MigrationDelayBadge.tsx+++ b/web/src/features/v4-migration/V4MigrationDelayBadge.tsx@@ -7,8 +7,8 @@ import {} from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { useForceV3Experience } from "@/src/features/v4-migration/useForceV3Experience";import { PARTNER_INTEGRATION_FAQ_URL } from "@/src/features/v4-migration/partnerIntegrationDocs";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useQueryProject } from "@/src/features/projects";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useQueryProject } from "@/src/features/projects/hooks";import { useOpenV4MigrationPanel } from "@/src/features/v4-migration/hooks/useOpenV4MigrationPanel";import {useProjectV4EvalData,@@ -22,7 +22,7 @@ import {} from "@/src/features/v4-migration/sdkVersionStatus";import { EvaluatorMigrationDialog } from "@/src/features/v4-migration/EvaluatorMigrationDialog";import { buildDeprecatedRulesUrl } from "@/src/features/v4-migration/evaluatorMigrationUrls";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";// The pill's description finishes expanding after 300ms (V4MigrationBadgeContent),// so a 500ms dwell means the full text was on screen — a drive-by mouse passdiff --git a/web/src/features/v4-migration/V4MigrationNavItem.tsx b/web/src/features/v4-migration/V4MigrationNavItem.tsxindex 8ef39d7509..53d454fcd4 100644--- a/web/src/features/v4-migration/V4MigrationNavItem.tsx+++ b/web/src/features/v4-migration/V4MigrationNavItem.tsx@@ -1,8 +1,8 @@import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";import { SidebarMenuButton, useSidebar } from "@/src/components/ui/sidebar";import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useQueryProject } from "@/src/features/projects";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useQueryProject } from "@/src/features/projects/hooks";import { useProjectV4MigrationActions } from "@/src/features/v4-migration/hooks/useV4MigrationData";import { useOpenV4MigrationPanel } from "@/src/features/v4-migration/hooks/useOpenV4MigrationPanel";diff --git a/web/src/features/v4-migration/V4MigrationPanel.tsx b/web/src/features/v4-migration/V4MigrationPanel.tsxindex 6bfab1926a..57623c0a21 100644--- a/web/src/features/v4-migration/V4MigrationPanel.tsx+++ b/web/src/features/v4-migration/V4MigrationPanel.tsx@@ -2,7 +2,7 @@import { X } from "@langfuse/icons";import { Button } from "@/src/components/ui/button";import { useV4MigrationPanel } from "@/src/features/v4-migration/V4MigrationPanelProvider";-import { useQueryProject } from "@/src/features/projects";+import { useQueryProject } from "@/src/features/projects/hooks";import {V4MigrationHeaderContent,V4MigrationDetailsContent,diff --git a/web/src/features/v4-migration/V4MigrationPanelProvider.tsx b/web/src/features/v4-migration/V4MigrationPanelProvider.tsxindex 7fa1660256..b8156b81fc 100644--- a/web/src/features/v4-migration/V4MigrationPanelProvider.tsx+++ b/web/src/features/v4-migration/V4MigrationPanelProvider.tsx@@ -4,10 +4,10 @@ import {useState,type PropsWithChildren,} from "react";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import type { ProjectMigrationReadiness } from "@/src/features/v4-migration/migrationData";-import { useQueryProject } from "@/src/features/projects";+import { useQueryProject } from "@/src/features/projects/hooks";export type V4MigrationTargetProject = {id: string;diff --git a/web/src/features/v4-migration/V4MigrationProjectChip.tsx b/web/src/features/v4-migration/V4MigrationProjectChip.tsxindex c972d8d513..440d547c2c 100644--- a/web/src/features/v4-migration/V4MigrationProjectChip.tsx+++ b/web/src/features/v4-migration/V4MigrationProjectChip.tsx@@ -1,5 +1,5 @@import { type V4MigrationTargetProject } from "@/src/features/v4-migration/V4MigrationPanelProvider";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { type ProjectMigrationReadiness } from "@/src/features/v4-migration/migrationData";import { useOpenV4MigrationPanel } from "@/src/features/v4-migration/hooks/useOpenV4MigrationPanel";import { PARTNER_INTEGRATION_FAQ_URL } from "@/src/features/v4-migration/partnerIntegrationDocs";diff --git a/web/src/features/v4-migration/V4MigrationStatusPage.tsx b/web/src/features/v4-migration/V4MigrationStatusPage.tsxindex d19767d6d1..86158d6bec 100644--- a/web/src/features/v4-migration/V4MigrationStatusPage.tsx+++ b/web/src/features/v4-migration/V4MigrationStatusPage.tsx@@ -18,7 +18,7 @@ import {V4MigrationDocsLink,V4_MIGRATION_DEADLINE,} from "@/src/features/v4-migration/V4MigrationContent";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { api } from "@/src/utils/api";import { formatCompactRelativeTime } from "@/src/utils/dates";import { V4MigrationStatusDot } from "@/src/features/v4-migration/V4MigrationBadgeContent";@@ -37,7 +37,8 @@ import {} from "@/src/features/v4-migration/migrationData";import { PARTNER_INTEGRATION_FAQ_URL } from "@/src/features/v4-migration/partnerIntegrationDocs";import { V4MigrationLoadingState } from "@/src/features/v4-migration/V4MigrationLoadingState";-import { useReadPath, V4PreviewToggleRow } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";+import { V4PreviewToggleRow } from "@/src/features/events/components/V4SidebarToggle";const V4_DOCS_URL = "https://langfuse.com/docs/v4";const SDK_UPGRADE_URL =diff --git a/web/src/features/v4-migration/hooks/useOpenV4MigrationPanel.ts b/web/src/features/v4-migration/hooks/useOpenV4MigrationPanel.tsindex 11a312e0e0..b8fb7c7be4 100644--- a/web/src/features/v4-migration/hooks/useOpenV4MigrationPanel.ts+++ b/web/src/features/v4-migration/hooks/useOpenV4MigrationPanel.ts@@ -1,5 +1,5 @@-import { useInAppAiAgent } from "@/src/features/in-app-agent";-import { useSupportDrawer } from "@/src/features/support-chat";+import { useInAppAiAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";import {useV4MigrationPanel,type V4MigrationPanelOpenSource,diff --git a/web/src/features/v4-migration/hooks/useV4MigrationData.ts b/web/src/features/v4-migration/hooks/useV4MigrationData.tsindex 01ad45b91a..cd11516428 100644--- a/web/src/features/v4-migration/hooks/useV4MigrationData.ts+++ b/web/src/features/v4-migration/hooks/useV4MigrationData.ts@@ -3,7 +3,7 @@ import {countActionableLegacyApiEntrypoints,isActionableLegacyApiUsage,normalizeLegacyApiEntrypoint,-} from "@/src/features/v4";+} from "@/src/features/v4/utils";import {getLegacyIntegrationLabels,getMigrationActionState,diff --git a/web/src/features/v4-migration/sdkVersionStatus.ts b/web/src/features/v4-migration/sdkVersionStatus.tsindex 98ebf7074f..13d6fb81e6 100644--- a/web/src/features/v4-migration/sdkVersionStatus.ts+++ b/web/src/features/v4-migration/sdkVersionStatus.ts@@ -1,6 +1,6 @@/* eslint-disable no-nested-ternary */import { type RouterOutputs } from "@/src/utils/api";-import { type SdkVersionInfo } from "@/src/features/sdk-version";+import type { SdkVersionInfo } from "@/src/features/sdk-version/lib/sdkVersionCapabilities";import { LANGFUSE_SDK_LATEST_MAJOR } from "@langfuse/shared";type V4MigrationSdkStatus =diff --git a/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts b/web/src/features/v4-migration/useV4UpgradeAssistantSupport.tsindex b7f663042e..20177ce8cd 100644--- a/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts+++ b/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts@@ -1,5 +1,5 @@/* eslint-disable no-nested-ternary */-import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent";+import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";import { useProjectV4SdkData } from "@/src/features/v4-migration/hooks/useV4MigrationData";import { api } from "@/src/utils/api";diff --git a/web/src/features/v4/index.ts b/web/src/features/v4/index.tsdeleted file mode 100644index 3bcd2f4876..0000000000--- a/web/src/features/v4/index.ts+++ /dev/null@@ -1,5 +0,0 @@-export {- countActionableLegacyApiEntrypoints,- isActionableLegacyApiUsage,- normalizeLegacyApiEntrypoint,-} from "@/src/features/v4/utils";diff --git a/web/src/features/v4/server/index.ts b/web/src/features/v4/server/index.tsdeleted file mode 100644index b463fe6d57..0000000000--- a/web/src/features/v4/server/index.ts+++ /dev/null@@ -1 +0,0 @@-export { getProjectV4MigrationData } from "@/src/features/v4/server/v4TransitionService";diff --git a/web/src/features/v4/server/v4TransitionSdkUsage.ts b/web/src/features/v4/server/v4TransitionSdkUsage.tsindex 9801905d4a..6a1fed73d9 100644--- a/web/src/features/v4/server/v4TransitionSdkUsage.ts+++ b/web/src/features/v4/server/v4TransitionSdkUsage.ts@@ -13,7 +13,7 @@ import {queryClickhouse,type IngestionSdkAttributionStatus,} from "@langfuse/shared/src/server";-import { getSdkVersionCapabilityStatus } from "@/src/features/sdk-version/server";+import { getSdkVersionCapabilityStatus } from "@/src/features/sdk-version/lib/sdkVersionCapabilities";import { getExperimentPostUsageByProject } from "@/src/features/v4/server/v4TransitionQueryLogUsage";import {getV4TransitionDetectionWindow,diff --git a/web/src/features/version-update/index.ts b/web/src/features/version-update/index.tsdeleted file mode 100644index f45808957c..0000000000--- a/web/src/features/version-update/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { VersionUpdateBanner } from "./VersionUpdateBanner";-export { useVersionUpdatePrompt } from "./useVersionUpdatePrompt";diff --git a/web/src/features/version-update/useVersionUpdatePrompt.ts b/web/src/features/version-update/useVersionUpdatePrompt.tsindex a6ab8f5ea8..1c4943165d 100644--- a/web/src/features/version-update/useVersionUpdatePrompt.ts+++ b/web/src/features/version-update/useVersionUpdatePrompt.ts@@ -1,5 +1,5 @@import { useEffect } from "react";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useAppSettled } from "./useAppSettled";import { useVersionUpdateAvailable } from "./useVersionUpdateAvailable";import { versionUpdateStore } from "./versionUpdateStore";diff --git a/web/src/features/web-callouts/components/WebCalloutButton.tsx b/web/src/features/web-callouts/components/WebCalloutButton.tsxindex 1a371ceff7..4d249847fe 100644--- a/web/src/features/web-callouts/components/WebCalloutButton.tsx+++ b/web/src/features/web-callouts/components/WebCalloutButton.tsx@@ -7,7 +7,8 @@ import {TooltipContent,TooltipTrigger,} from "@/src/components/ui/tooltip";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsxindex 2ebf1d76c1..753aa90df7 100644--- a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx+++ b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx@@ -1,5 +1,6 @@/* eslint-disable @typescript-eslint/no-deprecated, @typescript-eslint/no-use-before-define -- Legacy UI usage retained during migration to design-system components. */-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { zodResolver } from "@hookform/resolvers/zod";import { Plus, X } from "@langfuse/icons";import { useState } from "react";@@ -34,7 +35,7 @@ import {TooltipTrigger,} from "@/src/components/ui/tooltip";import { areDestinationUrlsEquivalent } from "@/src/features/automations/destinationUrl";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {WEB_CALLOUT_BLOCKED_HEADER_NAMES,WEB_CALLOUT_HEADER_NAME_PATTERN,diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsxindex 78d880ee9b..524fa385cf 100644--- a/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx+++ b/web/src/features/web-callouts/components/WebCalloutSettingsTable/ConnectedWebCalloutSettingsTable.tsx@@ -2,7 +2,8 @@ import { useMemo } from "react";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { type AsyncTableData } from "@/src/components/design-system/table/Table";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import {diff --git a/web/src/features/web-callouts/index.ts b/web/src/features/web-callouts/index.tsdeleted file mode 100644index 9c2c0ff96e..0000000000--- a/web/src/features/web-callouts/index.ts+++ /dev/null@@ -1,7 +0,0 @@-// The web-callouts feature's public client surface (RFC rule 8). Named-// re-exports only — exactly what other features already imported.-export {- useWebCalloutAction,- WebCalloutButton,-} from "@/src/features/web-callouts/components/WebCalloutButton";-export { useWebCallouts } from "@/src/features/web-callouts/useWebCallouts";diff --git a/web/src/features/web-callouts/server/router.ts b/web/src/features/web-callouts/server/router.tsindex 23f0dda4ce..898ca371a7 100644--- a/web/src/features/web-callouts/server/router.ts+++ b/web/src/features/web-callouts/server/router.ts@@ -1,8 +1,8 @@import { z } from "zod";import { TRPCError } from "@trpc/server";-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {WebCalloutEndpointUpsertInputSchema,WebCalloutInvokeInputSchema,diff --git a/web/src/features/web-callouts/useWebCallouts.ts b/web/src/features/web-callouts/useWebCallouts.tsindex c005966d29..0b50213d1c 100644--- a/web/src/features/web-callouts/useWebCallouts.ts+++ b/web/src/features/web-callouts/useWebCallouts.ts@@ -1,5 +1,5 @@import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { api } from "@/src/utils/api";// A project can have several endpoints; the integration counts as active asdiff --git a/web/src/features/widgets/EditWidgetPage.tsx b/web/src/features/widgets/EditWidgetPage.tsxindex 67488478f1..4e5c5563e3 100644--- a/web/src/features/widgets/EditWidgetPage.tsx+++ b/web/src/features/widgets/EditWidgetPage.tsx@@ -3,11 +3,12 @@ import Page from "@/src/components/layouts/Page";import { api } from "@/src/utils/api";import { ConnectedWidgetForm } from "@/src/features/widgets/components/ConnectedWidgetForm";import { type WidgetSavePayload } from "@/src/features/widgets/components/widgetFormSchema";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { type metricAggregations, type views } from "@langfuse/shared/query";import { type z } from "zod";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useReadPath } from "@/src/features/events";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";export default function EditWidgetPage() {diff --git a/web/src/features/widgets/NewWidgetPage.tsx b/web/src/features/widgets/NewWidgetPage.tsxindex d75bbb2787..fbaeb53cd3 100644--- a/web/src/features/widgets/NewWidgetPage.tsx+++ b/web/src/features/widgets/NewWidgetPage.tsx@@ -2,17 +2,18 @@import { useRouter } from "next/router";import Page from "@/src/components/layouts/Page";import { api } from "@/src/utils/api";-import { ConnectedWidgetForm } from "@/src/features/widgets";+import { ConnectedWidgetForm } from "@/src/features/widgets/components/ConnectedWidgetForm";import { type WidgetSavePayload } from "@/src/features/widgets/components/widgetFormSchema";-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { type metricAggregations, type views } from "@langfuse/shared/query";import { type z } from "zod";import { SelectDashboardDialog } from "@/src/features/dashboard/components/SelectDashboardDialog";import { useState } from "react";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { getDefaultView } from "@/src/features/widgets/utils";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import {asSingleQueryParam,diff --git a/web/src/features/widgets/WidgetsPage.tsx b/web/src/features/widgets/WidgetsPage.tsxindex 6766aa52e9..bfbc6d553f 100644--- a/web/src/features/widgets/WidgetsPage.tsx+++ b/web/src/features/widgets/WidgetsPage.tsx@@ -1,10 +1,13 @@import { useRouter } from "next/router";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import Page from "@/src/components/layouts/Page";import { ActionButton } from "@/src/components/ActionButton";import { PlusIcon } from "@langfuse/icons";-import { ConnectedDashboardWidgetTable } from "@/src/features/widgets";-import { getDashboardTabs, DASHBOARD_TABS } from "@/src/features/navigation";+import { ConnectedDashboardWidgetTable } from "@/src/features/widgets/components/WidgetTable/ConnectedDashboardWidgetTable";+import {+ getDashboardTabs,+ DASHBOARD_TABS,+} from "@/src/features/navigation/utils/dashboard-tabs";export default function WidgetsPage() {const router = useRouter();diff --git a/web/src/features/widgets/components/DashboardGrid.tsx b/web/src/features/widgets/components/DashboardGrid.tsxindex 27acba9bf2..d0f664cf7b 100644--- a/web/src/features/widgets/components/DashboardGrid.tsx+++ b/web/src/features/widgets/components/DashboardGrid.tsx@@ -1,14 +1,16 @@import { Responsive } from "react-grid-layout";import "react-grid-layout/css/styles.css";import "react-resizable/css/styles.css";-import { type WidgetPlacement } from "../components/DashboardWidget";+import {+ DashboardWidget,+ type WidgetPlacement,+} from "@/src/features/widgets/components/DashboardWidget";import { type WidgetExportSource } from "@/src/features/widgets/utils/import-export-utils";import {PresetDashboardWidget,type PresetPlacement,} from "../components/PresetDashboardWidget";-import { DashboardWidget } from "@/src/features/widgets";-import type { ResolvedReadPath } from "@/src/features/events";+import type { ResolvedReadPath } from "@/src/features/events/hooks/useReadPath";import { type FilterState } from "@langfuse/shared";import { useState, useEffect, useRef, useCallback } from "react";import { type ChartProps } from "@/src/features/widgets/chart-library/chart-props";diff --git a/web/src/features/widgets/components/DashboardWidget.tsx b/web/src/features/widgets/components/DashboardWidget.tsxindex 52e0de6833..b24a499b99 100644--- a/web/src/features/widgets/components/DashboardWidget.tsx+++ b/web/src/features/widgets/components/DashboardWidget.tsx@@ -1,5 +1,6 @@/* eslint-disable no-nested-ternary */-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { useCallback, useEffect, useMemo, useState } from "react";import { api } from "@/src/utils/api";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";@@ -34,8 +35,8 @@ import { useRouter } from "next/router";import {buildTableFilterHref,buildViewAsTableHint,-} from "@/src/features/dashboard";-import { useHasProjectAccess } from "@/src/features/rbac";+} from "@/src/features/dashboard/lib/buildTableFilterHref";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { downloadChartDataCsv } from "@/src/features/widgets/chart-library/downloadChartDataCsv";import {buildWidgetExport,@@ -58,10 +59,10 @@ import {getChartLoadingProgress,getChartLoadingStateProps,} from "@/src/features/widgets/chart-library/chartLoadingStateUtils";-import type { ResolvedReadPath } from "@/src/features/events";+import type { ResolvedReadPath } from "@/src/features/events/hooks/useReadPath";import { useScheduledDashboardExecuteQuery } from "@/src/features/dashboard/hooks/DashboardQuerySchedulerProvider";import { CopyWidgetDialog } from "@/src/features/widgets/components/CopyWidgetDialog";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Badge } from "@/src/components/design-system/Badge/Badge";export interface WidgetPlacement {diff --git a/web/src/features/widgets/components/InlineWidget.tsx b/web/src/features/widgets/components/InlineWidget.tsxindex 8262e9e2d8..07dc3f802b 100644--- a/web/src/features/widgets/components/InlineWidget.tsx+++ b/web/src/features/widgets/components/InlineWidget.tsx@@ -27,7 +27,7 @@ import {type WidgetChartConfig,} from "@/src/features/widgets/utils";import { isTimeSeriesChart } from "@/src/features/widgets/chart-library/utils";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { cn } from "@/src/utils/tailwind";// ============================================================================diff --git a/web/src/features/widgets/components/PresetDashboardWidget.tsx b/web/src/features/widgets/components/PresetDashboardWidget.tsxindex 215d0d282e..6c35c6db73 100644--- a/web/src/features/widgets/components/PresetDashboardWidget.tsx+++ b/web/src/features/widgets/components/PresetDashboardWidget.tsx@@ -1,5 +1,6 @@-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useEffect, useMemo, useRef } from "react";import {CopyIcon,@@ -10,7 +11,7 @@ import {} from "@langfuse/icons";import { type FilterState } from "@langfuse/shared";import { type ViewVersion } from "@langfuse/shared/query";-import type { ResolvedReadPath } from "@/src/features/events";+import type { ResolvedReadPath } from "@/src/features/events/hooks/useReadPath";import { findClosestDashboardInterval } from "@/src/utils/date-range-utils";import {getHomePreset,@@ -18,7 +19,7 @@ import {} from "@/src/features/dashboard/components/home-preset-registry";import { buildPresetExport } from "@/src/features/dashboard/utils/dashboard-import-export";import { copyTextToClipboard } from "@/src/utils/clipboard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";/**diff --git a/web/src/features/widgets/components/SelectWidgetDialog.tsx b/web/src/features/widgets/components/SelectWidgetDialog.tsxindex da47442af1..9d40c3ffd2 100644--- a/web/src/features/widgets/components/SelectWidgetDialog.tsx+++ b/web/src/features/widgets/components/SelectWidgetDialog.tsx@@ -2,7 +2,7 @@import React, { useEffect, useRef } from "react";import { useRouter } from "next/router";import { api } from "@/src/utils/api";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {Dialog,DialogContent,@@ -25,12 +25,10 @@ import {type ViewVersion,} from "@langfuse/shared/query";import { getHomePresetMetadata } from "@/src/features/dashboard/components/home-preset-registry";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";-import {- InAppAgentWidgetComposer,- useInAppAiAgent,-} from "@/src/features/in-app-agent";+import { InAppAgentWidgetComposer } from "@/src/features/in-app-agent/components/InAppAgentWidgetComposer";+import { useInAppAiAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";export type WidgetItem = {id: string;diff --git a/web/src/features/widgets/components/WidgetForm.tsx b/web/src/features/widgets/components/WidgetForm.tsxindex 92203f485c..5295cd9562 100644--- a/web/src/features/widgets/components/WidgetForm.tsx+++ b/web/src/features/widgets/components/WidgetForm.tsx@@ -24,7 +24,7 @@ import {import {mapWidgetUiTableFilterToView,partitionWidgetUiTableFiltersToView,-} from "@/src/features/dashboard";+} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import React, { useMemo, useRef } from "react";import {useController,@@ -40,12 +40,12 @@ import { Alert } from "@/src/components/design-system/Alert/Alert";import { type z } from "zod";-import { useReadPath } from "@/src/features/events";+import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { Input } from "@/src/components/design-system/Input/Input";import { FormField } from "@/src/components/design-system/FormField/FormField";import startCase from "lodash/startCase";import { DateRangeInput } from "@/src/components/design-system/DateRangeInput/DateRangeInput";-import { useEntitlementLimit } from "@/src/features/entitlements";+import { useEntitlementLimit } from "@/src/features/entitlements/hooks";import { addMinutes } from "date-fns";import { MetricsFilterBuilder } from "@/src/features/metrics/components/MetricsFilterBuilder";import { type useMetricsFilterBuilderData } from "@/src/features/metrics/components/ConnectedMetricsFilterBuilder";@@ -60,7 +60,7 @@ import {} from "@/src/utils/date-range-utils";import { Button } from "@/src/components/ui/button";import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { type FilterState } from "@langfuse/shared";import { isTimeSeriesChart } from "@/src/features/widgets/chart-library/utils";import {diff --git a/web/src/features/widgets/components/WidgetImporter.clienttest.tsx b/web/src/features/widgets/components/WidgetImporter.clienttest.tsxindex e2eed852b3..b4851ff677 100644--- a/web/src/features/widgets/components/WidgetImporter.clienttest.tsx+++ b/web/src/features/widgets/components/WidgetImporter.clienttest.tsx@@ -2,7 +2,8 @@import { describe, expect, it, vi } from "vitest";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { __test } from "./WidgetImporter";diff --git a/web/src/features/widgets/components/WidgetImporter.tsx b/web/src/features/widgets/components/WidgetImporter.tsxindex 9b00bdf6f0..cf2ac87f39 100644--- a/web/src/features/widgets/components/WidgetImporter.tsx+++ b/web/src/features/widgets/components/WidgetImporter.tsx@@ -6,8 +6,9 @@ import { type ViewVersion } from "@langfuse/shared/query";import { type TimeFilter, ObservationLevelDomain } from "@langfuse/shared";import { api, type RouterOutputs } from "@/src/utils/api";import { Button } from "@/src/components/ui/button";-import { normalizeSingleValueOptions } from "@/src/features/filters";-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { normalizeSingleValueOptions } from "@/src/features/filters/lib/filter-transform";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import {importWidgetFile,type ImportedWidgetFormSnapshot,diff --git a/web/src/features/widgets/components/WidgetTable/ConnectedDashboardWidgetTable.tsx b/web/src/features/widgets/components/WidgetTable/ConnectedDashboardWidgetTable.tsxindex 9d6958def1..865025e675 100644--- a/web/src/features/widgets/components/WidgetTable/ConnectedDashboardWidgetTable.tsx+++ b/web/src/features/widgets/components/WidgetTable/ConnectedDashboardWidgetTable.tsx@@ -1,11 +1,12 @@-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { useCallback, useEffect, useMemo, useState } from "react";import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";-import { useOrderByState } from "@/src/features/orderBy";+import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { NumberParam, useQueryParams, withDefault } from "use-query-params";import { api } from "@/src/utils/api";-import { useDetailPageLists } from "@/src/features/navigate-detail-pages";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useDetailPageLists } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {buildWidgetExport,downloadWidgetJson,@@ -14,7 +15,7 @@ import {} from "@/src/features/widgets/utils/import-export-utils";import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";import { copyTextToClipboard } from "@/src/utils/clipboard";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useRouter } from "next/router";import { type metricAggregations } from "@langfuse/shared/query";import { type z } from "zod";diff --git a/web/src/features/widgets/components/widgetFormAdapters.clienttest.ts b/web/src/features/widgets/components/widgetFormAdapters.clienttest.tsindex ca00f63554..1dfb00e7a6 100644--- a/web/src/features/widgets/components/widgetFormAdapters.clienttest.ts+++ b/web/src/features/widgets/components/widgetFormAdapters.clienttest.ts@@ -8,7 +8,7 @@ import { type metricAggregations } from "@langfuse/shared/query";import {mapWidgetUiTableFilterToView,normalizeStoredWidgetFiltersForEditor,-} from "@/src/features/dashboard";+} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import { isTimeSeriesChart } from "@/src/features/widgets/chart-library/utils";import {buildWidgetDescription,diff --git a/web/src/features/widgets/components/widgetFormSchema.ts b/web/src/features/widgets/components/widgetFormSchema.tsindex 1363e0687f..ab9ba3a3d6 100644--- a/web/src/features/widgets/components/widgetFormSchema.ts+++ b/web/src/features/widgets/components/widgetFormSchema.ts@@ -16,7 +16,7 @@ import {import {mapWidgetUiTableFilterToView,normalizeStoredWidgetFiltersForEditor,-} from "@/src/features/dashboard";+} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import { isTimeSeriesChart } from "@/src/features/widgets/chart-library/utils";import { dashboardWidgetChartTypeSchema } from "@/src/features/widgets/lib/dashboardWidgetChartTypes";import {diff --git a/web/src/features/widgets/hooks/useWidgetQueryErrorCapture.ts b/web/src/features/widgets/hooks/useWidgetQueryErrorCapture.tsindex 4b4530877f..b15b04146a 100644--- a/web/src/features/widgets/hooks/useWidgetQueryErrorCapture.ts+++ b/web/src/features/widgets/hooks/useWidgetQueryErrorCapture.ts@@ -1,7 +1,7 @@import { useEffect, useRef } from "react";import { type QueryValidationResult } from "@langfuse/shared/query";import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";type WidgetHighCardinalityErrorSurface =| "create_editor"diff --git a/web/src/features/widgets/index.ts b/web/src/features/widgets/index.tsdeleted file mode 100644index e80dd89d3c..0000000000--- a/web/src/features/widgets/index.ts+++ /dev/null@@ -1,45 +0,0 @@-// The widgets feature's public client surface (RFC rule 8). Named re-exports-// only — the chart library, widget components and import/export helpers other-// features already imported by file path.-//-// filters' multi-select and single-select, events' outlier-strip binning,-// and DashboardGrid stay on deep paths: routing them through this index-// would close runtime cycles between widgets and those features.-export { Chart } from "@/src/features/widgets/chart-library/Chart";-export { ChartLoadingState } from "@/src/features/widgets/chart-library/ChartLoadingState";-export { VerticalBarChartTimeSeries } from "@/src/features/widgets/chart-library/VerticalBarChartTimeSeries";-export { downloadChartDataCsv } from "@/src/features/widgets/chart-library/downloadChartDataCsv";-export type {- DataPoint,- LegendSummaryMode,- MetricFormatterFunction,- MissingBucketValue,-} from "@/src/features/widgets/chart-library/chart-props";-export { parseChartTimestamp } from "@/src/features/widgets/chart-library/prepareTimeAxis";-export {- formatMetric,- isTimeSeriesChart,-} from "@/src/features/widgets/chart-library/utils";-export type { DashboardPlacement } from "@/src/features/widgets/components/DashboardGrid";-export { useClipboardWidgetProbe } from "@/src/features/widgets/hooks/useClipboardWidgetProbe";-export { pushDownForInsertion } from "@/src/features/widgets/utils/grid-placement";-export { WidgetContent } from "@/src/features/widgets/components/InlineWidget";-export type { WidgetDimensionConfig } from "@/src/features/widgets/hooks/useWidgetQuery";-export {- getWidgetMetricPresentation,- getWidgetMissingBucketValue,-} from "@/src/features/widgets/utils";-export {- buildWidgetExport,- parseImportedWidgetJson,- parsePastedWidget,- toWidgetCreateFields,-} from "@/src/features/widgets/utils/import-export-utils";-export type {- PastedWidgetParseResult,- WidgetExportSource,- WidgetImport,-} from "@/src/features/widgets/utils/import-export-utils";-export { DashboardWidget } from "@/src/features/widgets/components/DashboardWidget";-export { ConnectedWidgetForm } from "@/src/features/widgets/components/ConnectedWidgetForm";-export { ConnectedDashboardWidgetTable } from "@/src/features/widgets/components/WidgetTable/ConnectedDashboardWidgetTable";diff --git a/web/src/features/widgets/server/index.ts b/web/src/features/widgets/server/index.tsdeleted file mode 100644index cd84105f0d..0000000000--- a/web/src/features/widgets/server/index.ts+++ /dev/null@@ -1,8 +0,0 @@-// The widgets feature's server surface (RFC rule 9, amended).-export {- createPublicDashboardWidget,- deletePublicDashboardWidget,- getPublicDashboardWidget,- listPublicDashboardWidgets,- updatePublicDashboardWidget,-} from "@/src/features/widgets/server/public-dashboard-widget-service";diff --git a/web/src/features/widgets/server/public-dashboard-widget-service.ts b/web/src/features/widgets/server/public-dashboard-widget-service.tsindex 7898923e1a..9882b30ffa 100644--- a/web/src/features/widgets/server/public-dashboard-widget-service.ts+++ b/web/src/features/widgets/server/public-dashboard-widget-service.ts@@ -13,18 +13,19 @@ import {getViewDeclaration,type ViewVersion,} from "@langfuse/shared/query";-import { auditLog } from "@/src/features/audit-logs/server";-import { createStructuredPublicApiError } from "@/src/features/public-api";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { createStructuredPublicApiError } from "@/src/features/public-api/types/structuredPublicApiError";import {PostUnstableDashboardWidgetResponse,type DashboardWidgetViewOutputType,type PostUnstableDashboardWidgetBodyType,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/types/unstable-dashboard-widgets";+import { ChartConfigSchema, LangfuseNotFoundError } from "@langfuse/shared";import {getWidgetImportFilterConfig,partitionStoredUiTableFiltersToView,-} from "@/src/features/dashboard/server";+} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import {MAX_PIVOT_TABLE_DIMENSIONS,MAX_PIVOT_TABLE_METRICS,diff --git a/web/src/features/widgets/utils.clienttest.ts b/web/src/features/widgets/utils.clienttest.tsindex 185443e502..a78e090f32 100644--- a/web/src/features/widgets/utils.clienttest.ts+++ b/web/src/features/widgets/utils.clienttest.ts@@ -1,5 +1,5 @@import { type FilterState } from "@langfuse/shared";-import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard";+import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import { mergeWidgetAndDashboardFilters } from "./utils";/**diff --git a/web/src/features/widgets/utils.ts b/web/src/features/widgets/utils.tsindex 464792809c..c3305ddc5f 100644--- a/web/src/features/widgets/utils.ts+++ b/web/src/features/widgets/utils.ts@@ -13,7 +13,7 @@ import {type MetricFormatterFunction,type MissingBucketValue,} from "@/src/features/widgets/chart-library/chart-props";-import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard";+import { mapLegacyUiTableFilterToView } from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";// Shared widget chart configuration typesexport type WidgetChartConfig = {diff --git a/web/src/features/widgets/utils/import-export-utils.ts b/web/src/features/widgets/utils/import-export-utils.tsindex bf446571c1..4ef802f140 100644--- a/web/src/features/widgets/utils/import-export-utils.ts+++ b/web/src/features/widgets/utils/import-export-utils.ts@@ -11,7 +11,7 @@ import {getWidgetImportFilterConfig,normalizeStoredWidgetFiltersForEditor,partitionStoredUiTableFiltersToView,-} from "@/src/features/dashboard";+} from "@/src/features/dashboard/lib/dashboardUiTableToViewMapping";import startCase from "lodash/startCase";import {ChartConfigSchema,diff --git a/web/src/hooks/useCollapsibleSystemPrompt.ts b/web/src/hooks/useCollapsibleSystemPrompt.tsindex 4a8772a609..1700a2a8a3 100644--- a/web/src/hooks/useCollapsibleSystemPrompt.ts+++ b/web/src/hooks/useCollapsibleSystemPrompt.ts@@ -1,5 +1,5 @@import { useMemo, useSyncExternalStore } from "react";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";// A prompt counts as long when it exceeds the char threshold and would not// fit a short first-lines preview anyway.diff --git a/web/src/hooks/useEnvLabel.clienttest.tsx b/web/src/hooks/useEnvLabel.clienttest.tsxindex 33644878d1..a1b88abfda 100644--- a/web/src/hooks/useEnvLabel.clienttest.tsx+++ b/web/src/hooks/useEnvLabel.clienttest.tsx@@ -12,7 +12,7 @@ vi.mock("next-auth/react", () => ({useSession: () => ({ data: { user: { email: mocks.email } } }),}));-vi.mock("@/src/features/organizations", () => ({+vi.mock("@/src/features/organizations/hooks", () => ({useLangfuseCloudRegion: () =>mocks.region === undefined? ({ isLangfuseCloud: false, region: undefined } as const)diff --git a/web/src/hooks/useEnvLabel.ts b/web/src/hooks/useEnvLabel.tsindex 60e8dd1ada..5a90176594 100644--- a/web/src/hooks/useEnvLabel.ts+++ b/web/src/hooks/useEnvLabel.ts@@ -1,4 +1,4 @@-import { useLangfuseCloudRegion } from "@/src/features/organizations";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";import { useSession } from "next-auth/react";import { useState } from "react";diff --git a/web/src/hooks/useUserSearch.ts b/web/src/hooks/useUserSearch.tsindex a5e6a08c89..b08691afaa 100644--- a/web/src/hooks/useUserSearch.ts+++ b/web/src/hooks/useUserSearch.ts@@ -1,6 +1,6 @@import { useState, useEffect } from "react";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";interface UseUserSearchProps {projectId: string;excludeUserIds?: string[];diff --git a/web/src/initialize.ts b/web/src/initialize.tsindex 2d0995280f..8ae882e237 100644--- a/web/src/initialize.ts+++ b/web/src/initialize.ts@@ -2,7 +2,7 @@ import { env } from "@/src/env.mjs";import { createUserEmailPassword } from "@/src/features/auth-credentials/lib/credentialsServerUtils";import { prisma } from "@langfuse/shared/src/db";import { createApiKey } from "@langfuse/shared/src/server/auth/apiKeys";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import { getOrganizationPlanServerSide } from "@/src/features/entitlements/server/getPlan";import { CloudConfigSchema } from "@langfuse/shared";import {diff --git a/web/src/pages/_app.tsx b/web/src/pages/_app.tsxindex 3313c684ab..796adf3a42 100644--- a/web/src/pages/_app.tsx+++ b/web/src/pages/_app.tsx@@ -85,24 +85,24 @@ if (typeof window !== "undefined") {}import { ResilientSessionProvider } from "@/src/features/auth/components/ResilientSessionProvider";-import { DetailPageListsProvider } from "@/src/features/navigate-detail-pages";+import { DetailPageListsProvider } from "@/src/features/navigate-detail-pages/DetailPageListsProvider";import { env } from "@/src/env.mjs";import { ThemeProvider } from "@/src/features/theming/ThemeProvider";import { MarkdownRenderCharacterLimitProvider } from "@/src/components/MarkdownRenderCharacterLimitProvider/MarkdownRenderCharacterLimitProvider";-import { SupportDrawerProvider } from "@/src/features/support-chat";+import { SupportDrawerProvider } from "@/src/features/support-chat/SupportDrawerProvider";import { V4MigrationPanelProvider } from "@/src/features/v4-migration/V4MigrationPanelProvider";import { installStaleChunkReloadListener } from "@/src/features/version-update/reloadOnStaleChunk";-import { InAppAiAgentProvider } from "@/src/features/in-app-agent";-import { useLangfuseCloudRegion } from "@/src/features/organizations";-import { ScoreCacheProvider } from "@/src/features/scores";-import { CorrectionCacheProvider } from "@/src/features/corrections";+import { InAppAiAgentProvider } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";+import { ScoreCacheProvider } from "@/src/features/scores/contexts/ScoreCacheProvider";+import { CorrectionCacheProvider } from "@/src/features/corrections/contexts/CorrectionCacheProvider";import { LayerProvider } from "@/src/context/LayerContext/LayerContext";+import { V4_BETA_ENABLED_POSTHOG_PROPERTY } from "@/src/features/posthog-analytics/usePostHogClientCapture";import {- V4_BETA_ENABLED_POSTHOG_PROPERTY,getPostHogClientConfig,isPostHogClientEnabled,isProductAnalyticsAvailable,-} from "@/src/features/posthog-analytics";+} from "@/src/features/posthog-analytics/productAnalyticsAvailability";// Session replay is a Langfuse Cloud feature, so self-hosted never records.// The product-analytics gate makes this redundant in HIPAA (PostHog is notdiff --git a/web/src/pages/account/settings/index.tsx b/web/src/pages/account/settings/index.tsxindex d4cd701e97..e965bd069f 100644--- a/web/src/pages/account/settings/index.tsx+++ b/web/src/pages/account/settings/index.tsx@@ -1,4 +1,4 @@-import { SettingsPage } from "@/src/features/settings";+import { SettingsPage } from "@/src/features/settings/SettingsPage";export default function AccountSettingsRoute() {return <SettingsPage scope="account" />;diff --git a/web/src/pages/api/admin/api-keys/index.ts b/web/src/pages/api/admin/api-keys/index.tsindex 160cfe4c4a..d594d05fd4 100644--- a/web/src/pages/api/admin/api-keys/index.ts+++ b/web/src/pages/api/admin/api-keys/index.ts@@ -7,7 +7,7 @@ import {redis,} from "@langfuse/shared/src/server";import { ApiAuthService } from "@/src/features/public-api/server/apiAuth";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";/*This API route is used by Langfuse Cloud to delete API keys for a project.We will work on admin APIs in the future. See the discussion here: https://github.com/orgs/langfuse/discussions/3243diff --git a/web/src/pages/api/admin/bullmq/index.ts b/web/src/pages/api/admin/bullmq/index.tsindex 3b32244b89..1d099b028e 100644--- a/web/src/pages/api/admin/bullmq/index.ts+++ b/web/src/pages/api/admin/bullmq/index.ts@@ -15,7 +15,7 @@ import {OtelIngestionQueue,SecondaryOtelIngestionQueue,} from "@langfuse/shared/src/server";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";/*This API route is used by Langfuse Cloud to retry failed bullmq jobs.*/diff --git a/web/src/pages/api/admin/ingestion-replay.ts b/web/src/pages/api/admin/ingestion-replay.tsindex 930b274344..0ed0e0f49e 100644--- a/web/src/pages/api/admin/ingestion-replay.ts+++ b/web/src/pages/api/admin/ingestion-replay.ts@@ -13,7 +13,7 @@ import {type QueueName,type TQueueJobTypes,} from "@langfuse/shared/src/server";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";const IngestionReplayBody = z.object({keys: z.array(z.string()).min(1).max(1000),});diff --git a/web/src/pages/api/admin/organizations/[organizationId]/apiKeys/[apiKeyId].ts b/web/src/pages/api/admin/organizations/[organizationId]/apiKeys/[apiKeyId].tsindex 044ec4a458..395f8df263 100644--- a/web/src/pages/api/admin/organizations/[organizationId]/apiKeys/[apiKeyId].ts+++ b/web/src/pages/api/admin/organizations/[organizationId]/apiKeys/[apiKeyId].ts@@ -1,12 +1,12 @@import { type NextApiRequest, type NextApiResponse } from "next";import { logger } from "@langfuse/shared/src/server";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";import {validateQueryParams,handleDeleteApiKey,} from "@/src/ee/features/admin-api/server/organizations/apiKeys/apiKeyById";import { prisma } from "@langfuse/shared/src/db";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import { getSelfHostedInstancePlanServerSide } from "@/src/features/entitlements/server/getPlan";export default async function handler(diff --git a/web/src/pages/api/admin/organizations/[organizationId]/apiKeys/index.ts b/web/src/pages/api/admin/organizations/[organizationId]/apiKeys/index.tsindex 65c0b3af39..94bdeb18e5 100644--- a/web/src/pages/api/admin/organizations/[organizationId]/apiKeys/index.ts+++ b/web/src/pages/api/admin/organizations/[organizationId]/apiKeys/index.ts@@ -1,14 +1,14 @@import { type NextApiRequest, type NextApiResponse } from "next";import { logger } from "@langfuse/shared/src/server";import { isBaseError } from "@langfuse/shared";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";import {validateQueryAndExtractId,handleGetApiKeys,handleCreateApiKey,} from "@/src/ee/features/admin-api/server/organizations/apiKeys";import { prisma } from "@langfuse/shared/src/db";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import { getSelfHostedInstancePlanServerSide } from "@/src/features/entitlements/server/getPlan";export default async function handler(diff --git a/web/src/pages/api/admin/organizations/[organizationId]/index.ts b/web/src/pages/api/admin/organizations/[organizationId]/index.tsindex ef255b3fef..894bc8a1a4 100644--- a/web/src/pages/api/admin/organizations/[organizationId]/index.ts+++ b/web/src/pages/api/admin/organizations/[organizationId]/index.ts@@ -1,12 +1,12 @@import { type NextApiRequest, type NextApiResponse } from "next";import { logger } from "@langfuse/shared/src/server";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";import {handleGetOrganizationById,handleUpdateOrganization,handleDeleteOrganization,} from "@/src/ee/features/admin-api/server/organizations/organizationById";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import { getSelfHostedInstancePlanServerSide } from "@/src/features/entitlements/server/getPlan";export default async function handler(diff --git a/web/src/pages/api/admin/organizations/index.ts b/web/src/pages/api/admin/organizations/index.tsindex 9f4da4c328..ecfe640d03 100644--- a/web/src/pages/api/admin/organizations/index.ts+++ b/web/src/pages/api/admin/organizations/index.ts@@ -1,11 +1,11 @@import { type NextApiRequest, type NextApiResponse } from "next";import { logger } from "@langfuse/shared/src/server";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";import {handleGetOrganizations,handleCreateOrganization,} from "@/src/ee/features/admin-api/server/organizations";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import { getSelfHostedInstancePlanServerSide } from "@/src/features/entitlements/server/getPlan";export default async function handler(diff --git a/web/src/pages/api/auth/check-sso.ts b/web/src/pages/api/auth/check-sso.tsindex 196606333e..9e71c12b8a 100644--- a/web/src/pages/api/auth/check-sso.ts+++ b/web/src/pages/api/auth/check-sso.ts@@ -4,7 +4,7 @@* If no custom SSO provider is configured or EE is not available, this API will return a 404 response.*/-import { getSsoAuthProviderIdForDomain } from "@/src/ee/features/multi-tenant-sso/server";+import { getSsoAuthProviderIdForDomain } from "@/src/ee/features/multi-tenant-sso/utils";import type { NextApiRequest, NextApiResponse } from "next";import { z } from "zod";diff --git a/web/src/pages/api/auth/signup-verify.ts b/web/src/pages/api/auth/signup-verify.tsindex 74450d53ac..e8e86adc9b 100644--- a/web/src/pages/api/auth/signup-verify.ts+++ b/web/src/pages/api/auth/signup-verify.ts@@ -1,5 +1,5 @@import { env } from "@/src/env.mjs";-import { isEmailVerificationRequired } from "@/src/features/auth-credentials";+import { isEmailVerificationRequired } from "@/src/features/auth-credentials/lib/credentialsUtils";import { validateSignupEligibility } from "@/src/features/auth-credentials/server/signupApiHandler";import { createProjectMembershipsOnSignup } from "@/src/features/auth/lib/createProjectMembershipsOnSignup";import { getAdClickIdsFromRequest } from "@/src/features/auth/lib/signupAttribution";diff --git a/web/src/pages/api/internal/ai-gateway/v1/models.ts b/web/src/pages/api/internal/ai-gateway/v1/models.tsindex 9b61b5f355..922189538f 100644--- a/web/src/pages/api/internal/ai-gateway/v1/models.ts+++ b/web/src/pages/api/internal/ai-gateway/v1/models.ts@@ -1,6 +1,4 @@-import {- gatewayModelsApiHandler,- withGatewayModelsSignatureVerification,-} from "@/src/features/ai-gateway/server";+import { gatewayModelsApiHandler } from "@/src/features/ai-gateway/server/provider/models/gatewayModelsApiHandler";+import { withGatewayModelsSignatureVerification } from "@/src/features/ai-gateway/server/auth/gatewayRequestSignatureVerifier";export default withGatewayModelsSignatureVerification(gatewayModelsApiHandler);diff --git a/web/src/pages/api/internal/ai-gateway/v1/resolve.ts b/web/src/pages/api/internal/ai-gateway/v1/resolve.tsindex 174620c459..a7941a7b5a 100644--- a/web/src/pages/api/internal/ai-gateway/v1/resolve.ts+++ b/web/src/pages/api/internal/ai-gateway/v1/resolve.ts@@ -1,7 +1,5 @@-import {- gatewayResolveApiHandler,- withGatewayResolveSignatureVerification,-} from "@/src/features/ai-gateway/server";+import { gatewayResolveApiHandler } from "@/src/features/ai-gateway/server/resolve/gatewayResolveApiHandler";+import { withGatewayResolveSignatureVerification } from "@/src/features/ai-gateway/server/auth/gatewayRequestSignatureVerifier";export default withGatewayResolveSignatureVerification(gatewayResolveApiHandler,diff --git a/web/src/pages/api/public/annotation-queues/[queueId]/assignments.ts b/web/src/pages/api/public/annotation-queues/[queueId]/assignments.tsindex 58fa222504..cfeb87207a 100644--- a/web/src/pages/api/public/annotation-queues/[queueId]/assignments.ts+++ b/web/src/pages/api/public/annotation-queues/[queueId]/assignments.ts@@ -10,7 +10,7 @@ import {import {createAnnotationQueueAssignmentForApi,deleteAnnotationQueueAssignmentForApi,-} from "@/src/features/annotation-queues/server";+} from "@/src/features/annotation-queues/server/publicAnnotationQueueService";export default withMiddlewares({POST: createAuthedProjectAPIRoute({name: "Create Annotation Queue Assignment",diff --git a/web/src/pages/api/public/annotation-queues/[queueId]/index.ts b/web/src/pages/api/public/annotation-queues/[queueId]/index.tsindex 2d164edd2a..51c72db06a 100644--- a/web/src/pages/api/public/annotation-queues/[queueId]/index.ts+++ b/web/src/pages/api/public/annotation-queues/[queueId]/index.ts@@ -4,7 +4,7 @@ import {GetAnnotationQueueByIdQuery,GetAnnotationQueueByIdResponse,} from "@/src/features/public-api/types/annotation-queues";-import { getAnnotationQueueForApi } from "@/src/features/annotation-queues/server";+import { getAnnotationQueueForApi } from "@/src/features/annotation-queues/server/publicAnnotationQueueService";export default withMiddlewares({GET: createAuthedProjectAPIRoute({diff --git a/web/src/pages/api/public/annotation-queues/[queueId]/items/[itemId].ts b/web/src/pages/api/public/annotation-queues/[queueId]/items/[itemId].tsindex 6a566158b0..fa322b4e1a 100644--- a/web/src/pages/api/public/annotation-queues/[queueId]/items/[itemId].ts+++ b/web/src/pages/api/public/annotation-queues/[queueId]/items/[itemId].ts@@ -12,7 +12,7 @@ import {deleteAnnotationQueueItemForApi,getAnnotationQueueItemForApi,updateAnnotationQueueItemForApi,-} from "@/src/features/annotation-queues/server";+} from "@/src/features/annotation-queues/server/publicAnnotationQueueService";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "Get annotation queue item by ID",diff --git a/web/src/pages/api/public/annotation-queues/[queueId]/items/index.ts b/web/src/pages/api/public/annotation-queues/[queueId]/items/index.tsindex bd962ad918..69707a9f48 100644--- a/web/src/pages/api/public/annotation-queues/[queueId]/items/index.ts+++ b/web/src/pages/api/public/annotation-queues/[queueId]/items/index.ts@@ -9,7 +9,7 @@ import {import {createAnnotationQueueItemForApi,listAnnotationQueueItemsForApi,-} from "@/src/features/annotation-queues/server";+} from "@/src/features/annotation-queues/server/publicAnnotationQueueService";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "Get annotation queue items",diff --git a/web/src/pages/api/public/annotation-queues/index.ts b/web/src/pages/api/public/annotation-queues/index.tsindex 58a06cbaf5..eb1c8dd4ba 100644--- a/web/src/pages/api/public/annotation-queues/index.ts+++ b/web/src/pages/api/public/annotation-queues/index.ts@@ -9,7 +9,7 @@ import {import {createAnnotationQueueForApi,listAnnotationQueuesForApi,-} from "@/src/features/annotation-queues/server";+} from "@/src/features/annotation-queues/server/publicAnnotationQueueService";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "Get annotation queues",diff --git a/web/src/pages/api/public/comments/[commentId].ts b/web/src/pages/api/public/comments/[commentId].tsindex 0cfec21cdf..c91e02fa69 100644--- a/web/src/pages/api/public/comments/[commentId].ts+++ b/web/src/pages/api/public/comments/[commentId].ts@@ -1,4 +1,4 @@-import { getCommentForApi } from "@/src/features/comments/server";+import { getCommentForApi } from "@/src/features/comments/server/publicCommentService";import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import {diff --git a/web/src/pages/api/public/comments/index.ts b/web/src/pages/api/public/comments/index.tsindex 932e72d6c4..b044223662 100644--- a/web/src/pages/api/public/comments/index.ts+++ b/web/src/pages/api/public/comments/index.ts@@ -3,7 +3,7 @@ import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/crimport {createCommentForApi,listCommentsForApi,-} from "@/src/features/comments/server";+} from "@/src/features/comments/server/publicCommentService";import {GetCommentsV1Query,GetCommentsV1Response,diff --git a/web/src/pages/api/public/experiment-items/index.ts b/web/src/pages/api/public/experiment-items/index.tsindex d6cdb97ca6..a46ede8d72 100644--- a/web/src/pages/api/public/experiment-items/index.ts+++ b/web/src/pages/api/public/experiment-items/index.ts@@ -7,8 +7,8 @@ import {GetExperimentItemsV1Query,GetExperimentItemsV1Response,} from "@/src/features/public-api/types/experiments";-import { listExperimentItemsForPublicApi } from "@/src/features/experiments/server/public";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { listExperimentItemsForPublicApi } from "@/src/features/experiments/server/public/service";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "Get Experiment Items",diff --git a/web/src/pages/api/public/experiments/index.ts b/web/src/pages/api/public/experiments/index.tsindex b5e3bdc0f4..e131aeba18 100644--- a/web/src/pages/api/public/experiments/index.ts+++ b/web/src/pages/api/public/experiments/index.ts@@ -7,8 +7,8 @@ import {GetExperimentsV1Query,GetExperimentsV1Response,} from "@/src/features/public-api/types/experiments";-import { listExperimentsForPublicApi } from "@/src/features/experiments/server/public";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { listExperimentsForPublicApi } from "@/src/features/experiments/server/public/service";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "Get Experiments",diff --git a/web/src/pages/api/public/feedback.ts b/web/src/pages/api/public/feedback.tsindex 644d38cd42..33655253c5 100644--- a/web/src/pages/api/public/feedback.ts+++ b/web/src/pages/api/public/feedback.ts@@ -1,6 +1,6 @@import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";-import { submitFeedback } from "@/src/features/feedback/server";+import { submitFeedback } from "@/src/features/feedback/server/FeedbackService";import {PostFeedbackBody,PostFeedbackResponse,diff --git a/web/src/pages/api/public/health.ts b/web/src/pages/api/public/health.tsindex ec199159bf..0d1c75a01a 100644--- a/web/src/pages/api/public/health.ts+++ b/web/src/pages/api/public/health.ts@@ -1,4 +1,4 @@-import { VERSION } from "@/src/constants";+import { VERSION } from "@/src/constants/VERSION";import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { clickHouseRouteForRequest } from "@/src/features/public-api/server/clickHouseRequestTags";import { runHealthCheck } from "@/src/features/public-api/server/health-service";diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.tsindex 35f60a7b0a..75bcee9e33 100644--- a/web/src/pages/api/public/ingestion.ts+++ b/web/src/pages/api/public/ingestion.ts@@ -42,8 +42,8 @@ import {import {shadowAuth,shadowAuthorize,- __dangerouslySkipAuthz,-} from "@/src/features/public-api/server";+} from "@/src/features/public-api/server/shadowAuth";+import { __dangerouslySkipAuthz } from "@/src/features/public-api/server/enforceAuth";import { type ProjectAction } from "@langfuse/shared/rbac";import {unauthorizedError,diff --git a/web/src/pages/api/public/integrations/blob-storage/[id].ts b/web/src/pages/api/public/integrations/blob-storage/[id].tsindex 93a0aadbac..917ec9ffa8 100644--- a/web/src/pages/api/public/integrations/blob-storage/[id].ts+++ b/web/src/pages/api/public/integrations/blob-storage/[id].ts@@ -1,7 +1,7 @@import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import { prisma } from "@langfuse/shared/src/db";import { type NextApiRequest, type NextApiResponse } from "next";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { InvalidRequestError, LangfuseNotFoundError } from "@langfuse/shared";import type { BlobStorageIntegrationStatusResponseType } from "@/src/features/public-api/types/blob-storage-integrations";import { deriveSyncStatus } from "@/src/features/blobstorage-integration/deriveSyncStatus";diff --git a/web/src/pages/api/public/integrations/blob-storage/index.ts b/web/src/pages/api/public/integrations/blob-storage/index.tsindex 44836648f4..2d348a98b9 100644--- a/web/src/pages/api/public/integrations/blob-storage/index.ts+++ b/web/src/pages/api/public/integrations/blob-storage/index.ts@@ -14,8 +14,8 @@ import {type ExportFieldGroup,} from "@langfuse/shared";import { upsertBlobStorageIntegration } from "@/src/features/blobstorage-integration/service";-import { resolveExportSource } from "@/src/features/analytics-integrations/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { resolveExportSource } from "@/src/features/analytics-integrations/server/exportSource";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { authorizeBlobStorageRequest } from "@/src/features/blobstorage-integration/authorizeBlobStorageRequest";export default withMiddlewares({diff --git a/web/src/pages/api/public/mcp/index.ts b/web/src/pages/api/public/mcp/index.tsindex c72b413347..ae3d1db278 100644--- a/web/src/pages/api/public/mcp/index.ts+++ b/web/src/pages/api/public/mcp/index.ts@@ -35,10 +35,8 @@ import { RateLimitService } from "@/src/features/public-api/server/RateLimitServimport { BaseError, ForbiddenError, safeJsonParse } from "@langfuse/shared";import { ZodError } from "zod";import { isUserInputError } from "@/src/features/mcp/core/errors";-import {- shadowAuth,- __dangerouslySkipAuthz,-} from "@/src/features/public-api/server";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { __dangerouslySkipAuthz } from "@/src/features/public-api/server/enforceAuth";import { IN_APP_AGENT_MCP_TOOL_OVERRIDE_HEADER } from "@langfuse/shared/in-app-agent";import { InAppAgentMcpRunOverrideSchema } from "@langfuse/shared/in-app-agent/server/mcpPolicy";diff --git a/web/src/pages/api/public/media/[mediaId].ts b/web/src/pages/api/public/media/[mediaId].tsindex d570803c7d..e9034cbe3b 100644--- a/web/src/pages/api/public/media/[mediaId].ts+++ b/web/src/pages/api/public/media/[mediaId].ts@@ -3,10 +3,12 @@ import { z } from "zod";import {getMedia,updateMediaUploadStatus,+} from "@/src/features/media/server/mediaService";+import {GetMediaQuerySchema,GetMediaResponseSchema,PatchMediaBodySchema,-} from "@/src/features/media/server";+} from "@/src/features/media/validation";import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import { ForbiddenError } from "@langfuse/shared";diff --git a/web/src/pages/api/public/media/index.ts b/web/src/pages/api/public/media/index.tsindex 299dd1dca5..001f986f00 100644--- a/web/src/pages/api/public/media/index.ts+++ b/web/src/pages/api/public/media/index.ts@@ -1,9 +1,9 @@import { env } from "@/src/env.mjs";+import { createMediaUploadUrl } from "@/src/features/media/server/mediaService";import {- createMediaUploadUrl,GetMediaUploadUrlQuerySchema,GetMediaUploadUrlResponseSchema,-} from "@/src/features/media/server";+} from "@/src/features/media/validation";import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import { ForbiddenError, InvalidRequestError } from "@langfuse/shared";diff --git a/web/src/pages/api/public/metrics/daily.ts b/web/src/pages/api/public/metrics/daily.tsindex c4ccdaa097..e2554ebce5 100644--- a/web/src/pages/api/public/metrics/daily.ts+++ b/web/src/pages/api/public/metrics/daily.ts@@ -9,7 +9,7 @@ import {getDailyMetricsCount,} from "@/src/features/public-api/server/dailyMetrics";import { METRICS_DEPRECATION } from "@/src/features/public-api/server/deprecations";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "Get Daily Metrics",diff --git a/web/src/pages/api/public/metrics/index.ts b/web/src/pages/api/public/metrics/index.tsindex 7b32347dc7..c4ebfee92d 100644--- a/web/src/pages/api/public/metrics/index.ts+++ b/web/src/pages/api/public/metrics/index.ts@@ -10,7 +10,7 @@ import {} from "@/src/features/public-api/types/metrics";import { executeQuery } from "@langfuse/shared/query/server";import { METRICS_DEPRECATION } from "@/src/features/public-api/server/deprecations";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({GET: createAuthedProjectAPIRoute({diff --git a/web/src/pages/api/public/models/[modelId]/index.ts b/web/src/pages/api/public/models/[modelId]/index.tsindex 7f35bfa66d..e0a8faba90 100644--- a/web/src/pages/api/public/models/[modelId]/index.ts+++ b/web/src/pages/api/public/models/[modelId]/index.ts@@ -12,7 +12,7 @@ import {deleteModelForApi,getModelForApi,upsertModelForApi,-} from "@/src/features/models/server";+} from "@/src/features/models/server/publicApiModelService";export default withMiddlewares({GET: createAuthedProjectAPIRoute({diff --git a/web/src/pages/api/public/models/index.ts b/web/src/pages/api/public/models/index.tsindex 14c5bf3639..b6900dbbc8 100644--- a/web/src/pages/api/public/models/index.ts+++ b/web/src/pages/api/public/models/index.ts@@ -9,7 +9,7 @@ import {import {createModelForApi,listModelsForApi,-} from "@/src/features/models/server";+} from "@/src/features/models/server/publicApiModelService";export default withMiddlewares({GET: createAuthedProjectAPIRoute({diff --git a/web/src/pages/api/public/observations/index.ts b/web/src/pages/api/public/observations/index.tsindex 99d2862381..8a965b594a 100644--- a/web/src/pages/api/public/observations/index.ts+++ b/web/src/pages/api/public/observations/index.ts@@ -21,7 +21,7 @@ import {} from "@/src/features/public-api/server/observations";import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";import { OBSERVATIONS_V1_DEPRECATION } from "@/src/features/public-api/server/deprecations";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({GET: createAuthedProjectAPIRoute({diff --git a/web/src/pages/api/public/organizations/apiKeys/index.ts b/web/src/pages/api/public/organizations/apiKeys/index.tsindex 7fbff00a0f..41a294fc05 100644--- a/web/src/pages/api/public/organizations/apiKeys/index.ts+++ b/web/src/pages/api/public/organizations/apiKeys/index.ts@@ -2,9 +2,10 @@ import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { logger } from "@langfuse/shared/src/server";import { RateLimitService } from "@/src/features/public-api/server/RateLimitService";import { handleGetApiKeys } from "@/src/ee/features/admin-api/server/organizations/apiKeys";-import { shadowAuth, writeOrgError } from "@/src/features/public-api/server";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeOrgError } from "@/src/features/public-api/server/writeError";import { type NextApiRequest, type NextApiResponse } from "next";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";export default async function handler(req: NextApiRequest,res: NextApiResponse,diff --git a/web/src/pages/api/public/organizations/llm-connections/[id].ts b/web/src/pages/api/public/organizations/llm-connections/[id].tsindex 05e8287d92..cdaae33567 100644--- a/web/src/pages/api/public/organizations/llm-connections/[id].ts+++ b/web/src/pages/api/public/organizations/llm-connections/[id].ts@@ -1,8 +1,6 @@import { LlmConnectionService } from "@/src/features/llm-api-key/server/llmConnectionService";-import {- authenticateOrganizationApiRequest,- withMiddlewares,-} from "@/src/features/public-api/server";+import { authenticateOrganizationApiRequest } from "@/src/features/public-api/server/authenticateOrganizationApiRequest";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import {DeleteLlmConnectionV1Query,DeleteLlmConnectionV1Response,diff --git a/web/src/pages/api/public/organizations/llm-connections/index.ts b/web/src/pages/api/public/organizations/llm-connections/index.tsindex e621cd3d18..eda65a46a9 100644--- a/web/src/pages/api/public/organizations/llm-connections/index.ts+++ b/web/src/pages/api/public/organizations/llm-connections/index.ts@@ -1,8 +1,6 @@import { LlmConnectionService } from "@/src/features/llm-api-key/server/llmConnectionService";-import {- authenticateOrganizationApiRequest,- withMiddlewares,-} from "@/src/features/public-api/server";+import { authenticateOrganizationApiRequest } from "@/src/features/public-api/server/authenticateOrganizationApiRequest";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import {GetLlmConnectionsV1Query,GetLlmConnectionsV1Response,diff --git a/web/src/pages/api/public/organizations/memberships/index.ts b/web/src/pages/api/public/organizations/memberships/index.tsindex 2aaa833181..47c4465eca 100644--- a/web/src/pages/api/public/organizations/memberships/index.ts+++ b/web/src/pages/api/public/organizations/memberships/index.ts@@ -5,9 +5,10 @@ import {handleGetMemberships,handleUpdateMembership,} from "@/src/ee/features/admin-api/server/memberships";-import { authenticator } from "@/src/features/apiKey/server";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import { shadowAuth, writeOrgError } from "@/src/features/public-api/server";+import { authenticator } from "@/src/features/apiKey/authenticator";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeOrgError } from "@/src/features/public-api/server/writeError";import { RateLimitService } from "@/src/features/public-api/server/RateLimitService";import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { BaseError } from "@langfuse/shared";diff --git a/web/src/pages/api/public/organizations/projects/index.ts b/web/src/pages/api/public/organizations/projects/index.tsindex dc760df635..f6a9f04375 100644--- a/web/src/pages/api/public/organizations/projects/index.ts+++ b/web/src/pages/api/public/organizations/projects/index.ts@@ -2,9 +2,10 @@ import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { logger } from "@langfuse/shared/src/server";import { RateLimitService } from "@/src/features/public-api/server/RateLimitService";import { handleGetProjects } from "@/src/ee/features/admin-api/server/projects";-import { shadowAuth, writeOrgError } from "@/src/features/public-api/server";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeOrgError } from "@/src/features/public-api/server/writeError";import { type NextApiRequest, type NextApiResponse } from "next";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";export default async function handler(req: NextApiRequest,res: NextApiResponse,diff --git a/web/src/pages/api/public/projects/[projectId]/apiKeys/[apiKeyId].ts b/web/src/pages/api/public/projects/[projectId]/apiKeys/[apiKeyId].tsindex b12f7cd212..dba71d4467 100644--- a/web/src/pages/api/public/projects/[projectId]/apiKeys/[apiKeyId].ts+++ b/web/src/pages/api/public/projects/[projectId]/apiKeys/[apiKeyId].ts@@ -7,11 +7,9 @@ import {validateQueryParams,handleDeleteApiKey,} from "@/src/ee/features/admin-api/server/projects/projectById/apiKeys/apiKeyById";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import {- shadowAuth,- writeProjectError,-} from "@/src/features/public-api/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeProjectError } from "@/src/features/public-api/server/writeError";/** handler deletes project keys for authorized organization credentials. */export default async function handler(diff --git a/web/src/pages/api/public/projects/[projectId]/apiKeys/index.ts b/web/src/pages/api/public/projects/[projectId]/apiKeys/index.tsindex cd08e14cd4..f7e4c47b71 100644--- a/web/src/pages/api/public/projects/[projectId]/apiKeys/index.ts+++ b/web/src/pages/api/public/projects/[projectId]/apiKeys/index.ts@@ -9,11 +9,9 @@ import {handleGetApiKeys,handleCreateApiKey,} from "@/src/ee/features/admin-api/server/projects/projectById/apiKeys";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import {- shadowAuth,- writeProjectError,-} from "@/src/features/public-api/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeProjectError } from "@/src/features/public-api/server/writeError";export default async function handler(req: NextApiRequest,diff --git a/web/src/pages/api/public/projects/[projectId]/index.ts b/web/src/pages/api/public/projects/[projectId]/index.tsindex 2e22b1b3da..e44dd1527f 100644--- a/web/src/pages/api/public/projects/[projectId]/index.ts+++ b/web/src/pages/api/public/projects/[projectId]/index.ts@@ -5,12 +5,10 @@ import {handleUpdateProject,handleDeleteProject,} from "@/src/ee/features/admin-api/server/projects/projectById";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";import { type NextApiRequest, type NextApiResponse } from "next";-import {- shadowAuth,- writeProjectError,-} from "@/src/features/public-api/server";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeProjectError } from "@/src/features/public-api/server/writeError";export default async function handler(req: NextApiRequest,diff --git a/web/src/pages/api/public/projects/[projectId]/memberships/index.ts b/web/src/pages/api/public/projects/[projectId]/memberships/index.tsindex 02c88a3e64..023ec234a7 100644--- a/web/src/pages/api/public/projects/[projectId]/memberships/index.ts+++ b/web/src/pages/api/public/projects/[projectId]/memberships/index.ts@@ -5,10 +5,11 @@ import {handleGetMemberships,handleUpdateMembership,} from "@/src/ee/features/admin-api/server/projects/projectById/memberships";-import { authenticator } from "@/src/features/apiKey/server";+import { authenticator } from "@/src/features/apiKey/authenticator";import { type AuthorizationContext } from "@/src/features/auth/policy/types";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import { shadowAuth, writeOrgError } from "@/src/features/public-api/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeOrgError } from "@/src/features/public-api/server/writeError";import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { BaseError } from "@langfuse/shared";import { prisma } from "@langfuse/shared/src/db";diff --git a/web/src/pages/api/public/projects/index.ts b/web/src/pages/api/public/projects/index.tsindex 384db3ce08..bcc2afd545 100644--- a/web/src/pages/api/public/projects/index.ts+++ b/web/src/pages/api/public/projects/index.ts@@ -3,11 +3,9 @@ import { prisma } from "@langfuse/shared/src/db";import { logger } from "@langfuse/shared/src/server";import { handleCreateProject } from "@/src/ee/features/admin-api/server/projects/createProject";import { type NextApiRequest, type NextApiResponse } from "next";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import {- shadowAuth,- writeProjectError,-} from "@/src/features/public-api/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeProjectError } from "@/src/features/public-api/server/writeError";/** projectKeyRequired is the 403 body when the project-scoped GET receives a non-project key. */const projectKeyRequired =diff --git a/web/src/pages/api/public/prompts.ts b/web/src/pages/api/public/prompts.tsindex 47598df81a..7f07ade479 100644--- a/web/src/pages/api/public/prompts.ts+++ b/web/src/pages/api/public/prompts.ts@@ -1,11 +1,9 @@import { z } from "zod";import { getPromptByName } from "@/src/features/prompts/server/actions/getPromptByName";-import { createPromptForApi } from "@/src/features/prompts/server";-import {- createAuthedProjectAPIRoute,- withMiddlewares,-} from "@/src/features/public-api/server";+import { createPromptForApi } from "@/src/features/prompts/server/prompt-api-service";+import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import { telemetry } from "@/src/features/telemetry";import {GetPromptSchema,diff --git a/web/src/pages/api/public/ready.ts b/web/src/pages/api/public/ready.tsindex 90245ed8c9..a20a85ba9d 100644--- a/web/src/pages/api/public/ready.ts+++ b/web/src/pages/api/public/ready.ts@@ -1,4 +1,4 @@-import { VERSION } from "@/src/constants";+import { VERSION } from "@/src/constants/VERSION";import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { telemetry } from "@/src/features/telemetry";import { isSigtermReceived } from "@/src/utils/shutdown";diff --git a/web/src/pages/api/public/scim/ResourceTypes.ts b/web/src/pages/api/public/scim/ResourceTypes.tsindex 288e4fba39..4959cb7067 100644--- a/web/src/pages/api/public/scim/ResourceTypes.ts+++ b/web/src/pages/api/public/scim/ResourceTypes.ts@@ -1,6 +1,7 @@import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { logger } from "@langfuse/shared/src/server";-import { shadowAuth, writeScimError } from "@/src/features/public-api/server";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeScimError } from "@/src/features/public-api/server/writeError";import { type NextApiRequest, type NextApiResponse } from "next";export default async function handler(diff --git a/web/src/pages/api/public/scim/Schemas.ts b/web/src/pages/api/public/scim/Schemas.tsindex 75187c9fc0..5795cb11f7 100644--- a/web/src/pages/api/public/scim/Schemas.ts+++ b/web/src/pages/api/public/scim/Schemas.ts@@ -1,6 +1,7 @@import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { logger } from "@langfuse/shared/src/server";-import { shadowAuth, writeScimError } from "@/src/features/public-api/server";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeScimError } from "@/src/features/public-api/server/writeError";import { type NextApiRequest, type NextApiResponse } from "next";export default async function handler(diff --git a/web/src/pages/api/public/scim/ServiceProviderConfig.ts b/web/src/pages/api/public/scim/ServiceProviderConfig.tsindex 5a636eba1c..1d6be7da1f 100644--- a/web/src/pages/api/public/scim/ServiceProviderConfig.ts+++ b/web/src/pages/api/public/scim/ServiceProviderConfig.ts@@ -1,6 +1,7 @@import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { logger } from "@langfuse/shared/src/server";-import { shadowAuth, writeScimError } from "@/src/features/public-api/server";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeScimError } from "@/src/features/public-api/server/writeError";import { type NextApiRequest, type NextApiResponse } from "next";export default async function handler(diff --git a/web/src/pages/api/public/scim/Users/[id].ts b/web/src/pages/api/public/scim/Users/[id].tsindex f7b346d47c..d65c355016 100644--- a/web/src/pages/api/public/scim/Users/[id].ts+++ b/web/src/pages/api/public/scim/Users/[id].ts@@ -1,5 +1,5 @@import { cors, runMiddleware } from "@/src/features/public-api/server/cors";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {deleteUserBoundApiKeys,deleteUserBoundApiKeysForRole,@@ -12,10 +12,11 @@ import { z } from "zod";import { type NextApiRequest, type NextApiResponse } from "next";import { assertValidOwnershipChange } from "@/src/ee/features/admin-api/server/memberships";import { requireGatewayEnabledForRole } from "@/src/features/ai-gateway/server/availability";-import { getSfdcService } from "@/src/ee/features/sfdc-sync/server";+import { getSfdcService } from "@/src/ee/features/sfdc-sync/server/sfdcService";import { type AuthorizationContext } from "@/src/features/auth/policy/types";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import { shadowAuth, writeScimError } from "@/src/features/public-api/server";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeScimError } from "@/src/features/public-api/server/writeError";// Parse the first valid role from a SCIM `roles` array. Returns undefined when// the attribute is absent, empty, or unparsable, which the provisioning logicdiff --git a/web/src/pages/api/public/scim/Users/index.ts b/web/src/pages/api/public/scim/Users/index.tsindex fb51449e0e..c8fa852fbe 100644--- a/web/src/pages/api/public/scim/Users/index.ts+++ b/web/src/pages/api/public/scim/Users/index.ts@@ -5,12 +5,13 @@ import { env } from "@/src/env.mjs";import { type NextApiRequest, type NextApiResponse } from "next";import { z } from "zod";import { isBaseError, type Role } from "@langfuse/shared";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { assertValidOwnershipChange } from "@/src/ee/features/admin-api/server/memberships";import { requireGatewayEnabledForRole } from "@/src/features/ai-gateway/server/availability";-import { getSfdcService } from "@/src/ee/features/sfdc-sync/server";-import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server";-import { shadowAuth, writeScimError } from "@/src/features/public-api/server";+import { getSfdcService } from "@/src/ee/features/sfdc-sync/server/sfdcService";+import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";+import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";+import { writeScimError } from "@/src/features/public-api/server/writeError";export default async function handler(req: NextApiRequest,res: NextApiResponse,diff --git a/web/src/pages/api/public/scores/index.ts b/web/src/pages/api/public/scores/index.tsindex 1c07b1c12c..377ad57c1f 100644--- a/web/src/pages/api/public/scores/index.ts+++ b/web/src/pages/api/public/scores/index.ts@@ -15,7 +15,7 @@ import {import { ScoresApiService } from "@/src/features/public-api/server/scores-api-service";import { SCORES_DEPRECATION } from "@/src/features/public-api/server/deprecations";import { randomUUID } from "crypto";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export const config = {api: {diff --git a/web/src/pages/api/public/sessions/index.ts b/web/src/pages/api/public/sessions/index.tsindex a802071dc0..0783926d53 100644--- a/web/src/pages/api/public/sessions/index.ts+++ b/web/src/pages/api/public/sessions/index.ts@@ -8,7 +8,7 @@ import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewareimport { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";import { SESSIONS_DEPRECATION } from "@/src/features/public-api/server/deprecations";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "Get Sessions",diff --git a/web/src/pages/api/public/skills/[skillName]/index.ts b/web/src/pages/api/public/skills/[skillName]/index.tsindex 09649f71e8..5e1b630139 100644--- a/web/src/pages/api/public/skills/[skillName]/index.ts+++ b/web/src/pages/api/public/skills/[skillName]/index.ts@@ -6,11 +6,9 @@ import {SkillVersionSchema,UpdateSkillTagsBodySchema,} from "@langfuse/shared";-import {- createAuthedProjectAPIRoute,- withMiddlewares,-} from "@/src/features/public-api/server";-import { SkillService } from "@/src/features/skills/server";+import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";+import { SkillService } from "@/src/features/skills/server/skill-service";import { GetSkillResponseSchema } from "@/src/features/public-api/types/skills";const querySchema = SkillSelectorSchema.and(diff --git a/web/src/pages/api/public/skills/[skillName]/versions/[skillVersion].ts b/web/src/pages/api/public/skills/[skillName]/versions/[skillVersion].tsindex 95f09f5c5b..47f03f5427 100644--- a/web/src/pages/api/public/skills/[skillName]/versions/[skillVersion].ts+++ b/web/src/pages/api/public/skills/[skillName]/versions/[skillVersion].ts@@ -6,11 +6,9 @@ import {SkillVersionSchema,UpdateSkillLabelsBodySchema,} from "@langfuse/shared";-import {- createAuthedProjectAPIRoute,- withMiddlewares,-} from "@/src/features/public-api/server";-import { SkillService } from "@/src/features/skills/server";+import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";+import { SkillService } from "@/src/features/skills/server/skill-service";const versionQuerySchema = z.object({skillName: SkillNameSchema,diff --git a/web/src/pages/api/public/skills/files/content.ts b/web/src/pages/api/public/skills/files/content.tsindex 3e1c78a5ba..ec9acbe20f 100644--- a/web/src/pages/api/public/skills/files/content.ts+++ b/web/src/pages/api/public/skills/files/content.ts@@ -1,13 +1,11 @@import { prisma } from "@langfuse/shared/src/db";-import {- createAuthedProjectAPIRoute,- withMiddlewares,-} from "@/src/features/public-api/server";+import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import {GetSkillFileContentsQuerySchema,GetSkillFileContentsResponseSchema,} from "@/src/features/public-api/types/skills";-import { SkillService } from "@/src/features/skills/server";+import { SkillService } from "@/src/features/skills/server/skill-service";export default withMiddlewares({GET: createAuthedProjectAPIRoute({diff --git a/web/src/pages/api/public/skills/index.ts b/web/src/pages/api/public/skills/index.tsindex 100765ae4e..f315205cab 100644--- a/web/src/pages/api/public/skills/index.ts+++ b/web/src/pages/api/public/skills/index.ts@@ -5,11 +5,9 @@ import {ListSkillsResponseSchema,SkillVersionSchema,} from "@langfuse/shared";-import {- createAuthedProjectAPIRoute,- withMiddlewares,-} from "@/src/features/public-api/server";-import { SkillService } from "@/src/features/skills/server";+import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";+import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";+import { SkillService } from "@/src/features/skills/server/skill-service";export const config = {api: {diff --git a/web/src/pages/api/public/slack/install/index.ts b/web/src/pages/api/public/slack/install/index.tsindex 9731570361..daf17369a4 100644--- a/web/src/pages/api/public/slack/install/index.ts+++ b/web/src/pages/api/public/slack/install/index.ts@@ -3,7 +3,7 @@ import { handleInstallPath } from "@/src/features/slack/server/oauth-handlers";import { logger } from "@langfuse/shared/src/server";import { cors, runMiddleware } from "@/src/features/public-api/server/cors";import { getServerAuthSession } from "@/src/server/auth";-import { hasProjectAccess } from "@/src/features/rbac";+import { hasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";export default async function handler(req: NextApiRequest,res: NextApiResponse,diff --git a/web/src/pages/api/public/traces/[traceId].ts b/web/src/pages/api/public/traces/[traceId].tsindex 3a89ea3d44..0ad5429671 100644--- a/web/src/pages/api/public/traces/[traceId].ts+++ b/web/src/pages/api/public/traces/[traceId].ts@@ -28,10 +28,10 @@ import {traceDeletionProcessor,} from "@langfuse/shared/src/server";import Decimal from "decimal.js";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";import { TRACES_DEPRECATION } from "@/src/features/public-api/server/deprecations";-import { recordPublicApiAccess } from "@/src/ee/features/access-audit-log/server";+import { recordPublicApiAccess } from "@/src/ee/features/access-audit-log/server/recordAccessEvent";export default withMiddlewares({diff --git a/web/src/pages/api/public/traces/index.ts b/web/src/pages/api/public/traces/index.tsindex d78a167ea4..f2fc5a56d9 100644--- a/web/src/pages/api/public/traces/index.ts+++ b/web/src/pages/api/public/traces/index.ts@@ -25,7 +25,7 @@ import {} from "@langfuse/shared/src/server";import { v4 } from "uuid";import { telemetry } from "@/src/features/telemetry";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import {generateTracesForPublicApi,getTracesCountForPublicApi,@@ -36,7 +36,7 @@ import {LEGACY_WRITES_DEPRECATION,TRACES_DEPRECATION,} from "@/src/features/public-api/server/deprecations";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({POST: createAuthedProjectAPIRoute({diff --git a/web/src/pages/api/public/unstable/dashboards/[dashboardId].ts b/web/src/pages/api/public/unstable/dashboards/[dashboardId].tsindex ce91faaa27..22ce67209f 100644--- a/web/src/pages/api/public/unstable/dashboards/[dashboardId].ts+++ b/web/src/pages/api/public/unstable/dashboards/[dashboardId].ts@@ -13,7 +13,7 @@ import {deletePublicDashboard,getPublicDashboard,updatePublicDashboard,-} from "@/src/features/dashboard/server";+} from "@/src/features/dashboard/server/public-dashboard-service";export default withUnstablePublicApiMiddlewares({GET: createUnstablePublicApiRoute({diff --git a/web/src/pages/api/public/unstable/dashboards/[dashboardId]/placements/[placementId].ts b/web/src/pages/api/public/unstable/dashboards/[dashboardId]/placements/[placementId].tsindex 9945668b89..c075887b72 100644--- a/web/src/pages/api/public/unstable/dashboards/[dashboardId]/placements/[placementId].ts+++ b/web/src/pages/api/public/unstable/dashboards/[dashboardId]/placements/[placementId].ts@@ -11,7 +11,7 @@ import {import {deletePublicDashboardPlacement,updatePublicDashboardPlacement,-} from "@/src/features/dashboard/server";+} from "@/src/features/dashboard/server/public-dashboard-service";export default withUnstablePublicApiMiddlewares({PATCH: createUnstablePublicApiRoute({diff --git a/web/src/pages/api/public/unstable/dashboards/[dashboardId]/placements/index.ts b/web/src/pages/api/public/unstable/dashboards/[dashboardId]/placements/index.tsindex 2851109303..2189ce47a7 100644--- a/web/src/pages/api/public/unstable/dashboards/[dashboardId]/placements/index.ts+++ b/web/src/pages/api/public/unstable/dashboards/[dashboardId]/placements/index.ts@@ -7,7 +7,7 @@ import {PostDashboardPlacementBody,PostDashboardPlacementResponse,} from "@/src/features/public-api/types/unstable-dashboards";-import { addPublicDashboardPlacement } from "@/src/features/dashboard/server";+import { addPublicDashboardPlacement } from "@/src/features/dashboard/server/public-dashboard-service";export default withUnstablePublicApiMiddlewares({POST: createUnstablePublicApiRoute({diff --git a/web/src/pages/api/public/unstable/dashboards/index.ts b/web/src/pages/api/public/unstable/dashboards/index.tsindex 7dbf345e20..da3b2e550f 100644--- a/web/src/pages/api/public/unstable/dashboards/index.ts+++ b/web/src/pages/api/public/unstable/dashboards/index.ts@@ -11,7 +11,7 @@ import {import {createPublicDashboard,listPublicDashboards,-} from "@/src/features/dashboard/server";+} from "@/src/features/dashboard/server/public-dashboard-service";export default withUnstablePublicApiMiddlewares({GET: createUnstablePublicApiRoute({diff --git a/web/src/pages/api/public/v2/evaluation-rules/[evaluationRuleId].ts b/web/src/pages/api/public/v2/evaluation-rules/[evaluationRuleId].tsindex 64c1ac60f9..0127628d09 100644--- a/web/src/pages/api/public/v2/evaluation-rules/[evaluationRuleId].ts+++ b/web/src/pages/api/public/v2/evaluation-rules/[evaluationRuleId].ts@@ -1 +1 @@-export { evaluationRuleApiHandler as default } from "@/src/features/public-api/server";+export { evaluationRuleApiHandler as default } from "@/src/features/public-api/server/evaluation/evaluationRuleApiHandler";diff --git a/web/src/pages/api/public/v2/evaluation-rules/index.ts b/web/src/pages/api/public/v2/evaluation-rules/index.tsindex 336cda3b18..f86eb97207 100644--- a/web/src/pages/api/public/v2/evaluation-rules/index.ts+++ b/web/src/pages/api/public/v2/evaluation-rules/index.ts@@ -1 +1 @@-export { evaluationRulesApiHandler as default } from "@/src/features/public-api/server";+export { evaluationRulesApiHandler as default } from "@/src/features/public-api/server/evaluation/evaluationRulesApiHandler";diff --git a/web/src/pages/api/public/v2/evaluators/[evaluatorId].ts b/web/src/pages/api/public/v2/evaluators/[evaluatorId].tsindex 6f7f385879..5403426b91 100644--- a/web/src/pages/api/public/v2/evaluators/[evaluatorId].ts+++ b/web/src/pages/api/public/v2/evaluators/[evaluatorId].ts@@ -1 +1 @@-export { evaluatorApiHandler as default } from "@/src/features/public-api/server";+export { evaluatorApiHandler as default } from "@/src/features/public-api/server/evaluation/evaluatorApiHandler";diff --git a/web/src/pages/api/public/v2/evaluators/[evaluatorId]/versions.ts b/web/src/pages/api/public/v2/evaluators/[evaluatorId]/versions.tsindex ce6ce09921..59cfa0fb82 100644--- a/web/src/pages/api/public/v2/evaluators/[evaluatorId]/versions.ts+++ b/web/src/pages/api/public/v2/evaluators/[evaluatorId]/versions.ts@@ -1 +1 @@-export { evaluatorVersionsApiHandler as default } from "@/src/features/public-api/server";+export { evaluatorVersionsApiHandler as default } from "@/src/features/public-api/server/evaluation/evaluatorVersionsApiHandler";diff --git a/web/src/pages/api/public/v2/evaluators/index.ts b/web/src/pages/api/public/v2/evaluators/index.tsindex 632118bf32..143574022d 100644--- a/web/src/pages/api/public/v2/evaluators/index.ts+++ b/web/src/pages/api/public/v2/evaluators/index.ts@@ -1 +1 @@-export { evaluatorsApiHandler as default } from "@/src/features/public-api/server";+export { evaluatorsApiHandler as default } from "@/src/features/public-api/server/evaluation/evaluatorsApiHandler";diff --git a/web/src/pages/api/public/v2/metrics.ts b/web/src/pages/api/public/v2/metrics.tsindex f7ae14c6a1..6ba1e4c491 100644--- a/web/src/pages/api/public/v2/metrics.ts+++ b/web/src/pages/api/public/v2/metrics.ts@@ -9,7 +9,7 @@ import {import { InvalidRequestError, LangfuseNotFoundError } from "@langfuse/shared";import { executeQuery } from "@langfuse/shared/query/server";import { validateQuery } from "@langfuse/shared/query";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";const DEFAULT_ROW_LIMIT = 100;export function isMetricsV2Available(): boolean {diff --git a/web/src/pages/api/public/v2/observations/index.ts b/web/src/pages/api/public/v2/observations/index.tsindex abea923dc4..36cb2b01cc 100644--- a/web/src/pages/api/public/v2/observations/index.ts+++ b/web/src/pages/api/public/v2/observations/index.ts@@ -13,7 +13,7 @@ import {GetObservationsV2Response,encodeCursor,} from "@/src/features/public-api/types/observations";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "Get Observations V2",diff --git a/web/src/pages/api/public/v2/scores/index.ts b/web/src/pages/api/public/v2/scores/index.tsindex 63ad341717..a8133115b1 100644--- a/web/src/pages/api/public/v2/scores/index.ts+++ b/web/src/pages/api/public/v2/scores/index.ts@@ -8,7 +8,7 @@ import {} from "@langfuse/shared";import { ScoresApiService } from "@/src/features/public-api/server/scores-api-service";import { SCORES_DEPRECATION } from "@/src/features/public-api/server/deprecations";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";export default withMiddlewares({GET: createAuthedProjectAPIRoute({name: "/api/public/scores",diff --git a/web/src/pages/api/public/v3/scores/index.ts b/web/src/pages/api/public/v3/scores/index.tsindex e83deae72a..c967b9c1b8 100644--- a/web/src/pages/api/public/v3/scores/index.ts+++ b/web/src/pages/api/public/v3/scores/index.ts@@ -1,9 +1,12 @@import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";import { GetScoresQueryV3, GetScoresResponseV3 } from "@langfuse/shared";-import { listScoresV3ForPublicApi } from "@/src/features/public-api/server/scores-api-v3";-import { EncodedScoresCursorV3 } from "@/src/features/public-api/types/scores";-import { clampToDataAccessDays } from "@/src/features/entitlements/server";+import {+ listScoresV3ForPublicApi,+ EncodedScoresCursorV3,+} from "@langfuse/shared/src/server";++import { clampToDataAccessDays } from "@/src/features/entitlements/server/hasEntitlementLimit";const GetScoresV3Query = GetScoresQueryV3.extend({cursor: EncodedScoresCursorV3.optional(),}).superRefine((data, ctx) => {diff --git a/web/src/pages/organization/[organizationId]/settings/[page].tsx b/web/src/pages/organization/[organizationId]/settings/[page].tsxindex 0279bc8083..7236693294 100644--- a/web/src/pages/organization/[organizationId]/settings/[page].tsx+++ b/web/src/pages/organization/[organizationId]/settings/[page].tsx@@ -1,7 +1,7 @@import { type GetServerSideProps } from "next";import { prisma } from "@langfuse/shared/src/db";-import { SettingsPage } from "@/src/features/settings";+import { SettingsPage } from "@/src/features/settings/SettingsPage";import { getGatewaySetupRedirect } from "@/src/features/ai-gateway/server/gatewaySetupRedirect";import { getServerAuthSession } from "@/src/server/auth";diff --git a/web/src/pages/organization/[organizationId]/settings/index.tsx b/web/src/pages/organization/[organizationId]/settings/index.tsxindex 664d81798f..facbccfc5f 100644--- a/web/src/pages/organization/[organizationId]/settings/index.tsx+++ b/web/src/pages/organization/[organizationId]/settings/index.tsx@@ -1,4 +1,4 @@-import { SettingsPage } from "@/src/features/settings";+import { SettingsPage } from "@/src/features/settings/SettingsPage";export default function OrganizationSettingsRoute() {return <SettingsPage scope="organization" />;diff --git a/web/src/pages/project/[projectId]/settings/billing.ts b/web/src/pages/project/[projectId]/settings/billing.tsindex baeb622b53..f6a61a155b 100644--- a/web/src/pages/project/[projectId]/settings/billing.ts+++ b/web/src/pages/project/[projectId]/settings/billing.ts@@ -1,4 +1,4 @@-import { useQueryProject } from "@/src/features/projects";+import { useQueryProject } from "@/src/features/projects/hooks";import { useRouter } from "next/router";import { useEffect } from "react";diff --git a/web/src/server/api/definitions/scoresTable.ts b/web/src/server/api/definitions/scoresTable.tsdeleted file mode 100644index a2c2ffee3f..0000000000--- a/web/src/server/api/definitions/scoresTable.ts+++ /dev/null@@ -1,3 +0,0 @@-import { scoresTableCols } from "@langfuse/shared";--export { scoresTableCols };diff --git a/web/src/server/api/root.ts b/web/src/server/api/root.tsindex ec924429a2..d8d39895ee 100644--- a/web/src/server/api/root.ts+++ b/web/src/server/api/root.ts@@ -5,7 +5,7 @@ import { eventsRouter } from "@/src/features/events/server/eventsRouter";import { scoresRouter } from "./routers/scores";import { scoreAnalyticsRouter } from "@/src/features/score-analytics/server/scoreAnalyticsRouter";import { dashboardRouter } from "@/src/features/dashboard/server/dashboard-router";-import { projectsRouter } from "@/src/features/projects/server";+import { projectsRouter } from "@/src/features/projects/server/projectsRouter";import { projectApiKeysRouter } from "@/src/features/public-api/server/projectApiKeyRouter";import { membersRouter } from "@/src/features/rbac/server/membersRouter";import { userRouter } from "@/src/server/api/routers/users";@@ -22,7 +22,7 @@ import { evaluatorRouter } from "@/src/features/evals/v2/server/evaluators/evaluimport { posthogIntegrationRouter } from "@/src/features/posthog-integration/posthog-integration-router";import { mixpanelIntegrationRouter } from "@/src/features/mixpanel-integration/mixpanel-integration-router";import { blobStorageIntegrationRouter } from "@/src/features/blobstorage-integration/blobstorage-integration-router";-import { externalMediaStorageRouter } from "@/src/features/external-media-storage/server";+import { externalMediaStorageRouter } from "@/src/features/external-media-storage/server/router";import { llmApiKeyRouter } from "@/src/features/llm-api-key/server/router";import { organizationLlmApiKeyRouter } from "@/src/features/llm-api-key/server/organizationRouter";import { llmSchemaRouter } from "@/src/features/llm-schemas/server/router";@@ -65,7 +65,7 @@ import { onboardingRouter } from "@/src/features/onboarding/server/onboardingRouimport { webCalloutsRouter } from "@/src/features/web-callouts/server/router";import { inAppAgentRouter } from "@/src/features/in-app-agent/server/router";import { v4TransitionRouter } from "@/src/features/v4/server/v4TransitionRouter";-import { aiGatewayRouter } from "@/src/features/ai-gateway/server";+import { aiGatewayRouter } from "@/src/features/ai-gateway/server/router";import { topicsRouter } from "@/src/features/topics/server/topicsRouter";import { skillRouter } from "@/src/features/skills/server/skill-router";diff --git a/web/src/server/api/routers/auditLogs.ts b/web/src/server/api/routers/auditLogs.tsindex 3ed8cb2b78..7e93c51042 100644--- a/web/src/server/api/routers/auditLogs.ts+++ b/web/src/server/api/routers/auditLogs.ts@@ -4,11 +4,9 @@ import {protectedProjectProcedure,protectedOrganizationProcedure,} from "../trpc";-import {- throwIfNoProjectAccess,- throwIfNoOrganizationAccess,-} from "@/src/features/rbac";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { throwIfNoOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";import { paginationZod } from "@langfuse/shared";import { AuditLogRecordType, type AuditLog } from "@langfuse/shared/src/db";diff --git a/web/src/server/api/routers/commentReactions.ts b/web/src/server/api/routers/commentReactions.tsindex 5646dad8dc..6192bcfa4b 100644--- a/web/src/server/api/routers/commentReactions.ts+++ b/web/src/server/api/routers/commentReactions.ts@@ -1,5 +1,8 @@import { z } from "zod";-import { throwIfNoProjectAccess, hasProjectAccess } from "@/src/features/rbac";+import {+ throwIfNoProjectAccess,+ hasProjectAccess,+} from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,diff --git a/web/src/server/api/routers/comments.ts b/web/src/server/api/routers/comments.tsindex 543b5e06b9..09101c2ce8 100644--- a/web/src/server/api/routers/comments.ts+++ b/web/src/server/api/routers/comments.ts@@ -1,6 +1,6 @@import { z } from "zod";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,@@ -11,7 +11,7 @@ import {CreateCommentData,DeleteCommentData,} from "@langfuse/shared";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { TRPCError } from "@trpc/server";import { validateCommentReferenceObject } from "@/src/features/comments/validateCommentReferenceObject";import {diff --git a/web/src/server/api/routers/dashboardWidgets.ts b/web/src/server/api/routers/dashboardWidgets.tsindex 948b8da3c9..1a556dfc48 100644--- a/web/src/server/api/routers/dashboardWidgets.ts+++ b/web/src/server/api/routers/dashboardWidgets.ts@@ -8,7 +8,7 @@ import {singleFilterList,optionalPaginationZod,} from "@langfuse/shared";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { DashboardWidgetChartType } from "@langfuse/shared/src/db";import {DashboardService,diff --git a/web/src/server/api/routers/generations/db/getAllGenerationsSqlQuery.ts b/web/src/server/api/routers/generations/db/getAllGenerationsSqlQuery.tsindex d5e9309d5d..8ad9802b3c 100644--- a/web/src/server/api/routers/generations/db/getAllGenerationsSqlQuery.ts+++ b/web/src/server/api/routers/generations/db/getAllGenerationsSqlQuery.ts@@ -1,4 +1,4 @@-import { aggregateScores } from "@/src/features/scores/server";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";import {filterAndValidateDbScoreList,LISTABLE_SCORE_TYPES,diff --git a/web/src/server/api/routers/generations/getAllQueries.ts b/web/src/server/api/routers/generations/getAllQueries.tsindex 665cc1dfd0..296a1fb2a2 100644--- a/web/src/server/api/routers/generations/getAllQueries.ts+++ b/web/src/server/api/routers/generations/getAllQueries.ts@@ -11,7 +11,7 @@ import {getObservationsTableCount,applyCommentFilters,} from "@langfuse/shared/src/server";-import { sanitizeLegacyTracingSearch } from "@/src/features/traces/server";+import { sanitizeLegacyTracingSearch } from "@/src/features/traces/server/legacyIoSearch";const GetAllGenerationsInput = GenerationTableOptions.safeExtend({...paginationZod,diff --git a/web/src/server/api/routers/media.ts b/web/src/server/api/routers/media.tsindex 4b30ee2279..ea5d11f68b 100644--- a/web/src/server/api/routers/media.ts+++ b/web/src/server/api/routers/media.ts@@ -7,13 +7,14 @@ import {protectedProjectProcedure,} from "@/src/server/api/trpc";import { TRPCError } from "@trpc/server";-import {- type MediaContentType,- type MediaReturnType,-} from "@/src/features/media/server";-import { type MediaEnabledFields } from "@/src/features/media/validation";-import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import type {+ MediaContentType,+ MediaReturnType,+ MediaEnabledFields,+} from "@/src/features/media/validation";++import { createExternalMediaStorageService } from "@/src/features/external-media-storage/server/service";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { InvalidRequestError } from "@langfuse/shared";import { logger } from "@langfuse/shared/src/server";diff --git a/web/src/server/api/routers/models.ts b/web/src/server/api/routers/models.tsindex 46e8be7cb6..e317c0114b 100644--- a/web/src/server/api/routers/models.ts+++ b/web/src/server/api/routers/models.ts@@ -1,15 +1,23 @@import { v4 as uuidv4 } from "uuid";import { z } from "zod";-import { isPrismaRecordNotFoundError } from "@/src/features/analytics-integrations/server";-import { auditLog } from "@/src/features/audit-logs/server";+import {+ isPrismaRecordNotFoundError,+ clearModelCacheForProject,+ queryClickhouse,+ findModel,+ hasPricingTierUsageDetails,+ matchPricingTier,+ escapeSqlLikePattern,+} from "@langfuse/shared/src/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { isValidPostgresRegex } from "@/src/features/models/server/isValidPostgresRegex";import {GetModelResultSchema,ModelLastUsedQueryResult,UpsertModelSchema,} from "@/src/features/models/validation";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,@@ -20,14 +28,7 @@ import {paginationZod,Prisma,} from "@langfuse/shared";-import {- clearModelCacheForProject,- queryClickhouse,- findModel,- hasPricingTierUsageDetails,- matchPricingTier,- escapeSqlLikePattern,-} from "@langfuse/shared/src/server";+import { TRPCError } from "@trpc/server";const ModelAllOptions = z.object({diff --git a/web/src/server/api/routers/monitors.ts b/web/src/server/api/routers/monitors.tsindex 365a89ef7e..7612b31bf1 100644--- a/web/src/server/api/routers/monitors.ts+++ b/web/src/server/api/routers/monitors.ts@@ -5,12 +5,10 @@ import {protectedProjectProcedure,requireV4Writes,} from "@/src/server/api/trpc";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { createWithinEntitlementLimit } from "@/src/features/entitlements/server/createWithinEntitlementLimit";-import {- listLinkedEvaluatorAlerts,- suggestMonitorName,-} from "@/src/features/monitors/server";+import { listLinkedEvaluatorAlerts } from "@/src/features/monitors/server/listLinkedEvaluatorAlerts";+import { suggestMonitorName } from "@/src/features/monitors/server/suggestMonitorName";import {CreateMonitorSchema,DeleteMonitorSchema,diff --git a/web/src/server/api/routers/notificationPreferences.ts b/web/src/server/api/routers/notificationPreferences.tsindex 555321d7d0..0fd27e06cf 100644--- a/web/src/server/api/routers/notificationPreferences.ts+++ b/web/src/server/api/routers/notificationPreferences.ts@@ -1,11 +1,11 @@import { z } from "zod";import { NotificationChannel, NotificationType } from "@prisma/client";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,} from "@/src/server/api/trpc";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";// Use enums from Prisma types to stay in sync with DB schemaconst NotificationChannelEnum = z.enum(NotificationChannel);const NotificationTypeEnum = z.enum(NotificationType);diff --git a/web/src/server/api/routers/scoreConfigs.ts b/web/src/server/api/routers/scoreConfigs.tsindex e1054a7839..d666969f27 100644--- a/web/src/server/api/routers/scoreConfigs.ts+++ b/web/src/server/api/routers/scoreConfigs.ts@@ -1,6 +1,6 @@import { z } from "zod";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,protectedProjectProcedure,@@ -18,7 +18,7 @@ import {validateDbScoreConfigSafe,} from "@langfuse/shared";import { traceException } from "@langfuse/shared/src/server";-import { auditLog } from "@/src/features/audit-logs/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";import { appendCategoryToExisting } from "@/src/features/scores/lib/annotationFormHelpers";const ScoreConfigAllInput = z.object({diff --git a/web/src/server/api/routers/scores.ts b/web/src/server/api/routers/scores.tsindex ec96f008dc..8c605e3dc8 100644--- a/web/src/server/api/routers/scores.ts+++ b/web/src/server/api/routers/scores.ts@@ -1,12 +1,12 @@import { z } from "zod";-import { throwIfNoProjectAccess } from "@/src/features/rbac";-import { auditLog } from "@/src/features/audit-logs/server";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { composeAggregateScoreKey } from "@/src/features/scores/lib/aggregateScores";import {- composeAggregateScoreKey,isNumericDataType,isTraceScore,-} from "@/src/features/scores/server";+} from "@/src/features/scores/lib/helpers";import {getDateFromOption,SelectedTimeOptionSchema,@@ -67,8 +67,8 @@ import {shouldSkipScoresDedup,} from "@langfuse/shared/src/server";import { v4 } from "uuid";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";-import { createBatchActionJob } from "@/src/features/table/server";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";+import { createBatchActionJob } from "@/src/features/table/server/createBatchActionJob";import { TRPCError } from "@trpc/server";import { randomUUID } from "crypto";import { toDomainWithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";diff --git a/web/src/server/api/routers/sessions.ts b/web/src/server/api/routers/sessions.tsindex 9d73d29005..e524e8422c 100644--- a/web/src/server/api/routers/sessions.ts+++ b/web/src/server/api/routers/sessions.ts@@ -1,6 +1,6 @@import { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {applyCommentFilters,traceException,@@ -54,7 +54,7 @@ import {import { TRPCError } from "@trpc/server";import Decimal from "decimal.js";import chunk from "lodash/chunk";-import { aggregateScores } from "@/src/features/scores/server";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";import {toDomainArrayWithStringifiedMetadata,toDomainWithStringifiedMetadata,diff --git a/web/src/server/api/routers/tableViewPresets.ts b/web/src/server/api/routers/tableViewPresets.tsindex 1f0fc82999..ff7eb1f5be 100644--- a/web/src/server/api/routers/tableViewPresets.ts+++ b/web/src/server/api/routers/tableViewPresets.ts@@ -4,7 +4,10 @@ import {createTRPCRouter,protectedProjectProcedure,} from "@/src/server/api/trpc";-import { hasProjectAccess, throwIfNoProjectAccess } from "@/src/features/rbac";+import {+ hasProjectAccess,+ throwIfNoProjectAccess,+} from "@/src/features/rbac/utils/checkProjectAccess";import {TableViewService,CreateTableViewPresetsInput,diff --git a/web/src/server/api/routers/traces.ts b/web/src/server/api/routers/traces.tsindex 60bcbdaf69..77d8647cc5 100644--- a/web/src/server/api/routers/traces.ts+++ b/web/src/server/api/routers/traces.ts@@ -1,7 +1,7 @@import { z } from "zod";-import { auditLog } from "@/src/features/audit-logs/server";-import { throwIfNoProjectAccess } from "@/src/features/rbac";-import { aggregateScores } from "@/src/features/scores/server";+import { auditLog } from "@/src/features/audit-logs/auditLog";+import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { aggregateScores } from "@/src/features/scores/lib/aggregateScores";import {applyCommentFilters,traceException,@@ -58,13 +58,14 @@ import {LangfuseNotFoundError,} from "@langfuse/shared";import { TRPCError } from "@trpc/server";-import { createBatchActionJob } from "@/src/features/table/server";-import { throwIfNoEntitlement } from "@/src/features/entitlements/server";-import { sanitizeLegacyTracingSearch } from "@/src/features/traces/server";+import { createBatchActionJob } from "@/src/features/table/server/createBatchActionJob";+import { throwIfNoEntitlement } from "@/src/features/entitlements/server/hasEntitlement";+import { sanitizeLegacyTracingSearch } from "@/src/features/traces/server/legacyIoSearch";import {type AgentGraphDataResponse,AgentGraphDataSchema,-} from "@/src/features/trace-graph-view/server";+} from "@/src/features/trace-graph-view/types";+import { env } from "@/src/env.mjs";import {toDomainWithStringifiedMetadata,diff --git a/web/src/server/api/routers/userAccount.ts b/web/src/server/api/routers/userAccount.tsindex e7ac853cc6..f0050cdca6 100644--- a/web/src/server/api/routers/userAccount.ts+++ b/web/src/server/api/routers/userAccount.ts@@ -6,17 +6,17 @@ import {import { TRPCError } from "@trpc/server";import { ForbiddenError, StringNoHTML } from "@langfuse/shared";import { Role, Prisma, type PrismaClient } from "@langfuse/shared/src/db";-import { canToggleV4 } from "@/src/features/events/server";+import { canToggleV4 } from "@/src/features/events/lib/v4Rollout";import { V4_PREVIEW_LABEL } from "@/src/features/events/lib/v4PreviewLabel";import { env } from "@/src/env.mjs";-import { getSfdcService } from "@/src/ee/features/sfdc-sync/server";+import { getSfdcService } from "@/src/ee/features/sfdc-sync/server/sfdcService";import {isAdminOnlyFeaturePreviewFlag,personalFeaturePreviewFlags,- setUserFeaturePreview,- hasInternalAccess,INTERNAL_FEATURE_FLAG,-} from "@/src/features/feature-flags/server";+} from "@/src/features/feature-flags/available-flags";+import { setUserFeaturePreview } from "@/src/features/feature-flags/server/organizationFeatureFlags";+import { hasInternalAccess } from "@/src/features/feature-flags/utils";import { advanceSessionsExpiredAtForUser } from "@/src/features/auth/lib/sessionExpiration";import {deleteUserBoundApiKeys,diff --git a/web/src/server/api/trpc.ts b/web/src/server/api/trpc.tsindex 4cb9974cd5..7c7fd15508 100644--- a/web/src/server/api/trpc.ts+++ b/web/src/server/api/trpc.ts@@ -106,7 +106,7 @@ import {isStorableTraceSessionId,} from "@langfuse/shared/src/server";-import { AdminApiAuthService } from "@/src/ee/features/admin-api/server";+import { AdminApiAuthService } from "@/src/ee/features/admin-api/server/adminApiAuth";import { env } from "@/src/env.mjs";import { isBaseError, parseIO } from "@langfuse/shared";import { recordBackendActivity } from "@/src/features/posthog-analytics/server/backendActivity";diff --git a/web/src/server/auth.ts b/web/src/server/auth.tsindex 9356a5d11c..be9176cfd9 100644--- a/web/src/server/auth.ts+++ b/web/src/server/auth.ts@@ -17,7 +17,7 @@ import {import {parseFlags,parseFlagsWithOrganizationDefaults,-} from "@/src/features/feature-flags/server";+} from "@/src/features/feature-flags/server/parseFlags";import {isGatewayDeployedOnInstance,isGatewayEnabledForOrganization,@@ -59,7 +59,7 @@ import {findMultiTenantSsoConfig,getSsoAuthProviderIdForDomain,loadSsoProviders,-} from "@/src/ee/features/multi-tenant-sso/server";+} from "@/src/ee/features/multi-tenant-sso/utils";import { getSupportAccessMemberships } from "@/src/ee/features/support-access/server/supportAccess";import {ENTERPRISE_SSO_REQUIRED_MESSAGE,@@ -95,9 +95,9 @@ import { createSupportEmailHash } from "@/src/features/support-chat/createSupporimport {canToggleV4,isV4UpgradeUiAvailable,-} from "@/src/features/events/server";-import { canCreateOrganizations } from "@/src/features/organizations/server";-import { isSignupOnboardingEnabled } from "@/src/features/onboarding/server";+} from "@/src/features/events/lib/v4Rollout";+import { canCreateOrganizations } from "@/src/features/organizations/server/canCreateOrganizations";+import { isSignupOnboardingEnabled } from "@/src/features/onboarding/server/onboardingService";const staticProviders: Provider[] = [CredentialsProvider({diff --git a/web/src/utils/chatml/adapters/index.ts b/web/src/utils/chatml/adapters/index.tsdeleted file mode 100644index 88046cc73f..0000000000--- a/web/src/utils/chatml/adapters/index.ts+++ /dev/null@@ -1,2 +0,0 @@-// Re-export everything from shared-export { normalizeInput, normalizeOutput } from "@langfuse/shared";diff --git a/web/src/utils/chatml/index.ts b/web/src/utils/chatml/index.tsdeleted file mode 100644index 0f2a829e7f..0000000000--- a/web/src/utils/chatml/index.ts+++ /dev/null@@ -1,8 +0,0 @@-// Re-export from shared (core functions moved to enable worker testing)-export {- cleanLegacyOutput,- extractAdditionalInput,- combineInputOutputMessages,- normalizeInput,- normalizeOutput,-} from "@langfuse/shared";diff --git a/web/src/utils/chatml/jumptoplayground.clienttest.ts b/web/src/utils/chatml/jumptoplayground.clienttest.tsindex dd1fd98983..1361d7b7a4 100644--- a/web/src/utils/chatml/jumptoplayground.clienttest.ts+++ b/web/src/utils/chatml/jumptoplayground.clienttest.ts@@ -72,7 +72,7 @@ vi.mock("@langfuse/shared", async () => {};});-import { normalizeInput, normalizeOutput } from "./adapters";+import { normalizeInput, normalizeOutput } from "@langfuse/shared";import { convertChatMlToPlayground } from "./playgroundConverter";import { extractTools } from "./extractTools";diff --git a/web/src/utils/decodeUnicodeInJson.ts b/web/src/utils/decodeUnicodeInJson.tsindex be43ca7c69..bbc7a83627 100644--- a/web/src/utils/decodeUnicodeInJson.ts+++ b/web/src/utils/decodeUnicodeInJson.ts@@ -1,4 +1,4 @@-import { decodeUnicodeEscapesOnly } from "@/src/utils/unicode";+import { decodeUnicodeEscapesOnly } from "@langfuse/shared";// Guards to keep decoding bounded on very large payloads. Exceeding either// limit returns the remainder undecoded (preserving browser responsivenessdiff --git a/web/src/utils/string.ts b/web/src/utils/string.tsdeleted file mode 100644index 072a2e4e1e..0000000000--- a/web/src/utils/string.ts+++ /dev/null@@ -1 +0,0 @@-export { truncate } from "@langfuse/shared";diff --git a/web/src/utils/trpcErrorToast.tsx b/web/src/utils/trpcErrorToast.tsxindex c79ba915cc..34b339ba69 100644--- a/web/src/utils/trpcErrorToast.tsx+++ b/web/src/utils/trpcErrorToast.tsx@@ -1,5 +1,5 @@import { TRPCClientError } from "@trpc/client";-import { showErrorToast } from "@/src/features/notifications";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { classifyTrpcToastError } from "@/src/utils/trpcErrorClassification";import { formatTrpcZodValidationDescription } from "@/src/utils/trpcValidationError";import type { ToastOperation } from "@/src/features/notifications/toastAnalytics";diff --git a/web/src/utils/unicode.clienttest.ts b/web/src/utils/unicode.clienttest.tsindex f1d32b04d1..06ec4c0172 100644--- a/web/src/utils/unicode.clienttest.ts+++ b/web/src/utils/unicode.clienttest.ts@@ -1,6 +1,6 @@// @vitest-environment node-import { decodeUnicodeEscapesOnly } from "@/src/utils/unicode";+import { decodeUnicodeEscapesOnly } from "@langfuse/shared";describe("decodeUnicodeEscapesOnly", () => {it("should decode basic Unicode escapes (Chinese, Korean)", () => {diff --git a/web/src/utils/unicode.ts b/web/src/utils/unicode.tsdeleted file mode 100644index dbb65b5ff7..0000000000--- a/web/src/utils/unicode.ts+++ /dev/null@@ -1 +0,0 @@-export { decodeUnicodeEscapesOnly } from "@langfuse/shared";diff --git a/worker/src/__tests__/helpers/otelReplaySetup.ts b/worker/src/__tests__/helpers/otelReplaySetup.tsindex 4433be8fbb..27777a699c 100644--- a/worker/src/__tests__/helpers/otelReplaySetup.ts+++ b/worker/src/__tests__/helpers/otelReplaySetup.ts@@ -49,10 +49,34 @@ vi.mock("@langfuse/shared/src/server", async (importOriginal) => ({}));vi.mock(- "../../features/evaluation/observationEval",+ "../../features/evaluation/observationEval/fetchObservationEvalRules",async (importOriginal) => ({...(await importOriginal<- typeof import("../../features/evaluation/observationEval")+ typeof import("../../features/evaluation/observationEval/fetchObservationEvalRules")+ >()),+ fetchObservationEvalRules: otelReplayMocks.fetchObservationEvalRules,+ createObservationEvalSchedulerDeps:+ otelReplayMocks.createObservationEvalSchedulerDeps,+ scheduleObservationEvals: otelReplayMocks.scheduleObservationEvals,+ }),+);+vi.mock(+ "../../features/evaluation/observationEval/createSchedulerDeps",+ async (importOriginal) => ({+ ...(await importOriginal<+ typeof import("../../features/evaluation/observationEval/createSchedulerDeps")+ >()),+ fetchObservationEvalRules: otelReplayMocks.fetchObservationEvalRules,+ createObservationEvalSchedulerDeps:+ otelReplayMocks.createObservationEvalSchedulerDeps,+ scheduleObservationEvals: otelReplayMocks.scheduleObservationEvals,+ }),+);+vi.mock(+ "../../features/evaluation/observationEval/scheduleObservationEvals",+ async (importOriginal) => ({+ ...(await importOriginal<+ typeof import("../../features/evaluation/observationEval/scheduleObservationEvals")>()),fetchObservationEvalRules: otelReplayMocks.fetchObservationEvalRules,createObservationEvalSchedulerDeps:diff --git a/worker/src/__tests__/outbound-connection-validation.test.ts b/worker/src/__tests__/outbound-connection-validation.test.tsindex 538507e21c..6a4c021c2e 100644--- a/worker/src/__tests__/outbound-connection-validation.test.ts+++ b/worker/src/__tests__/outbound-connection-validation.test.ts@@ -3,7 +3,7 @@ import { createServer, type Server } from "node:http";import { AddressInfo } from "node:net";import { afterEach, describe, expect, it, vi } from "vitest";import { logger } from "../../../packages/shared/src/server/logger";-import { fetchWithSecureRedirects } from "../../../packages/shared/src/server/outbound-url";+import { fetchWithSecureRedirects } from "../../../packages/shared/src/server/outbound-url/fetch";const strictWhitelist = { hosts: [], ips: [], ip_ranges: [] };diff --git a/worker/src/__tests__/processEventBatch.test.ts b/worker/src/__tests__/processEventBatch.test.tsindex 9e6c0b98eb..37f8320856 100644--- a/worker/src/__tests__/processEventBatch.test.ts+++ b/worker/src/__tests__/processEventBatch.test.ts@@ -1,7 +1,7 @@import { beforeEach, describe, it, expect, assert, vi } from "vitest";import { eventTypes } from "../../../packages/shared/src/server/ingestion/types";import { processEventBatch } from "../../../packages/shared/src/server/ingestion/processEventBatch";-import { ServiceUnavailableError } from "../../../packages/shared/src/errors";+import { ServiceUnavailableError } from "../../../packages/shared/src/errors/ServiceUnavailableError";import { logger } from "../../../packages/shared/src/server/logger";import {createUnknownSdkIngestionAttribution,diff --git a/worker/src/__tests__/traceBatching.test.ts b/worker/src/__tests__/traceBatching.test.tsindex 04aa2835ed..abf6fa717e 100644--- a/worker/src/__tests__/traceBatching.test.ts+++ b/worker/src/__tests__/traceBatching.test.ts@@ -117,12 +117,15 @@ vi.mock("../features/topics/models", () => ({embedTopicSummaries: vi.fn(),}));-vi.mock("../features/evaluation/observationEval", async (importOriginal) => ({- ...(await importOriginal<- typeof import("../features/evaluation/observationEval")- >()),- fetchObservationEvalRules: vi.fn().mockResolvedValue([]),-}));+vi.mock(+ "../features/evaluation/observationEval/fetchObservationEvalRules",+ async (importOriginal) => ({+ ...(await importOriginal<+ typeof import("../features/evaluation/observationEval/fetchObservationEvalRules")+ >()),+ fetchObservationEvalRules: vi.fn().mockResolvedValue([]),+ }),+);describe("trace batch selection", () => {const minute = 60_000;diff --git a/worker/src/__tests__/webhook-redirect-headers.test.ts b/worker/src/__tests__/webhook-redirect-headers.test.tsindex 2ad660ba32..bec34945af 100644--- a/worker/src/__tests__/webhook-redirect-headers.test.ts+++ b/worker/src/__tests__/webhook-redirect-headers.test.ts@@ -1,9 +1,7 @@import { afterEach, describe, expect, it, vi } from "vitest";import { logger } from "../../../packages/shared/src/server/logger";-import {- fetchWithSecureRedirects,- type OutboundUrlValidationWhitelist,-} from "../../../packages/shared/src/server/outbound-url";+import { fetchWithSecureRedirects } from "../../../packages/shared/src/server/outbound-url/fetch";+import type { OutboundUrlValidationWhitelist } from "../../../packages/shared/src/server/outbound-url/validation";const fetchMock = vi.fn<typeof fetch>();vi.stubGlobal("fetch", fetchMock);diff --git a/worker/src/backgroundMigrations/utils/v4BackfillDdl.ts b/worker/src/backgroundMigrations/utils/v4BackfillDdl.tsindex cbc5d1d5c3..04536aa651 100644--- a/worker/src/backgroundMigrations/utils/v4BackfillDdl.ts+++ b/worker/src/backgroundMigrations/utils/v4BackfillDdl.ts@@ -2,7 +2,7 @@ import { env } from "../../env";import {qualifiedClickhouseTableName,quoteClickhouseIdentifier,-} from "../../utils/clickhouseIdentifiers";+} from "@langfuse/shared/src/server/clickhouse/clickhouseIdentifiers";/*** Scratch table created by M2, read by M3/M4, dropped by M5. Single source ofdiff --git a/worker/src/features/batch-data-retention-cleaner/index.ts b/worker/src/features/batch-data-retention-cleaner/index.tsindex 72ffb275ed..283fa42ed4 100644--- a/worker/src/features/batch-data-retention-cleaner/index.ts+++ b/worker/src/features/batch-data-retention-cleaner/index.ts@@ -15,7 +15,7 @@ import {} from "@langfuse/shared/src/server";import { isEnterpriseLicenseAvailable } from "@langfuse/shared/src/server/ee/licenseCheck";import { env } from "../../env";-import { getRetentionCutoffDate } from "../utils";+import { getRetentionCutoffDate } from "../utils/utilities";import {PeriodicExclusiveRunner,PeriodicExclusiveRunnerLeaseLostError,diff --git a/worker/src/features/batchAction/processBatchedObservationEval.test.ts b/worker/src/features/batchAction/processBatchedObservationEval.test.tsindex b32e9d4cc4..b140fbe7ef 100644--- a/worker/src/features/batchAction/processBatchedObservationEval.test.ts+++ b/worker/src/features/batchAction/processBatchedObservationEval.test.ts@@ -5,10 +5,10 @@ import {EvalTemplateType,JobConfigState,} from "@langfuse/shared";-import {- type ObservationEvalRule,- type ObservationEvalSchedulerDeps,-} from "../evaluation/observationEval";+import type {+ ObservationEvalRule,+ ObservationEvalSchedulerDeps,+} from "../evaluation/observationEval/types";vi.mock("@langfuse/shared/src/db", () => ({prisma: {@@ -18,16 +18,16 @@ vi.mock("@langfuse/shared/src/db", () => ({},}));-vi.mock("../evaluation/observationEval", () => ({+vi.mock("../evaluation/observationEval/createSchedulerDeps", () => ({createObservationEvalSchedulerDeps: vi.fn(() => ({ deps: true })),+}));+vi.mock("../evaluation/observationEval/scheduleObservationEvals", () => ({scheduleObservationEvals: vi.fn().mockResolvedValue(undefined),}));import { prisma } from "@langfuse/shared/src/db";-import {- createObservationEvalSchedulerDeps,- scheduleObservationEvals,-} from "../evaluation/observationEval";+import { createObservationEvalSchedulerDeps } from "../evaluation/observationEval/createSchedulerDeps";+import { scheduleObservationEvals } from "../evaluation/observationEval/scheduleObservationEvals";import { processBatchedObservationEval } from "./processBatchedObservationEval";describe("processBatchedObservationEval", () => {@@ -252,8 +252,9 @@ describe("processBatchedObservationEval", () => {upsertJobExecution: vi.fn().mockResolvedValue({ id: "execution-1" }),enqueueEvalJob: vi.fn().mockRejectedValue(enqueueError),};- const actualModule =- await import("../evaluation/observationEval/scheduleObservationEvals");+ const actualModule = await vi.importActual<+ typeof import("../evaluation/observationEval/scheduleObservationEvals")+ >("../evaluation/observationEval/scheduleObservationEvals");vi.mocked(createObservationEvalSchedulerDeps).mockReturnValueOnce(schedulerDeps,diff --git a/worker/src/features/batchAction/processBatchedObservationEval.ts b/worker/src/features/batchAction/processBatchedObservationEval.tsindex e42865be64..33c4867613 100644--- a/worker/src/features/batchAction/processBatchedObservationEval.ts+++ b/worker/src/features/batchAction/processBatchedObservationEval.ts@@ -2,11 +2,9 @@ import pLimit from "p-limit";import { prisma } from "@langfuse/shared/src/db";import { BatchActionStatus, observationForEvalSchema } from "@langfuse/shared";import { logger, traceException } from "@langfuse/shared/src/server";-import {- createObservationEvalSchedulerDeps,- scheduleObservationEvals,- type ObservationEvalRule,-} from "../evaluation/observationEval";+import { createObservationEvalSchedulerDeps } from "../evaluation/observationEval/createSchedulerDeps";+import { scheduleObservationEvals } from "../evaluation/observationEval/scheduleObservationEvals";+import type { ObservationEvalRule } from "../evaluation/observationEval/types";const BATCH_SIZE = 500;const CONCURRENCY_LIMIT = 50;diff --git a/worker/src/features/deleted-mask-cleaner/helpers.ts b/worker/src/features/deleted-mask-cleaner/helpers.tsindex af4ef43c53..2ea435b410 100644--- a/worker/src/features/deleted-mask-cleaner/helpers.ts+++ b/worker/src/features/deleted-mask-cleaner/helpers.ts@@ -3,7 +3,7 @@ import {qualifiedClickhouseTableName,quoteClickhouseIdentifier,quoteClickhouseString,-} from "../../utils/clickhouseIdentifiers";+} from "@langfuse/shared/src/server/clickhouse/clickhouseIdentifiers";export const DELETED_MASK_CLEANER_TABLES = ["events_core",diff --git a/worker/src/features/evaluation/codeBased/executeCodeBasedEvaluation.ts b/worker/src/features/evaluation/codeBased/executeCodeBasedEvaluation.tsindex 19e392c482..edcf0de8e8 100644--- a/worker/src/features/evaluation/codeBased/executeCodeBasedEvaluation.ts+++ b/worker/src/features/evaluation/codeBased/executeCodeBasedEvaluation.ts@@ -13,7 +13,7 @@ import {type ExtractedVariable,} from "@langfuse/shared/src/server";import { UnrecoverableError } from "../../../errors/UnrecoverableError";-import { createW3CTraceId } from "../../utils";+import { createW3CTraceId } from "../../utils/utilities";import { type EvalExecutionResult } from "../evalCompletion";import { type EvalExecutionDeps } from "../evalExecutionDeps";diff --git a/worker/src/features/evaluation/codeBased/index.ts b/worker/src/features/evaluation/codeBased/index.tsdeleted file mode 100644index 7d97825c97..0000000000--- a/worker/src/features/evaluation/codeBased/index.ts+++ /dev/null@@ -1 +0,0 @@-export { executeCodeBasedEvaluation } from "./executeCodeBasedEvaluation";diff --git a/worker/src/features/evaluation/decisionModel/runDecisionModelEvaluation.ts b/worker/src/features/evaluation/decisionModel/runDecisionModelEvaluation.tsindex 3fdab0906b..be98ed1a10 100644--- a/worker/src/features/evaluation/decisionModel/runDecisionModelEvaluation.ts+++ b/worker/src/features/evaluation/decisionModel/runDecisionModelEvaluation.ts@@ -29,7 +29,7 @@ import {EvalFailureReason,UnrecoverableEvalFailureError,} from "../evalFailureErrors";-import { createW3CTraceId } from "../../utils";+import { createW3CTraceId } from "../../utils/utilities";import { type EvalExecutionResult } from "../evalCompletion";import { type EvalExecutionDeps } from "../evalExecutionDeps";import {diff --git a/worker/src/features/evaluation/evalService.ts b/worker/src/features/evaluation/evalService.tsindex 480ced39a4..204d286cde 100644--- a/worker/src/features/evaluation/evalService.ts+++ b/worker/src/features/evaluation/evalService.ts@@ -38,6 +38,7 @@ import {executeLlmEvaluator,type CodeEvalScoreWithName,type EvaluatorLlmErrorClassification,+ type ExtractedVariable,} from "@langfuse/shared/src/server";import {inMemoryFilterRequiresMetadata,@@ -70,7 +71,7 @@ import {} from "@langfuse/shared";import { env } from "../../env";import { prisma } from "@langfuse/shared/src/db";-import { createW3CTraceId } from "../utils";+import { createW3CTraceId } from "../utils/utilities";import { UnrecoverableError } from "../../errors/UnrecoverableError";import {EvalFailureReason,@@ -89,7 +90,7 @@ import {type EvalExecutionDeps,createProductionEvalExecutionDeps,} from "./evalExecutionDeps";-import { type ExtractedVariable } from "@langfuse/shared/src/server";+import {buildEvalExecutionSpanAttributes,buildEvaluatorLlmErrorSpanAttributes,diff --git a/worker/src/features/evaluation/observationEval/__tests__/observationEvalProcessor.test.ts b/worker/src/features/evaluation/observationEval/__tests__/observationEvalProcessor.test.tsindex 6e28937eaf..20ecb8ae14 100644--- a/worker/src/features/evaluation/observationEval/__tests__/observationEvalProcessor.test.ts+++ b/worker/src/features/evaluation/observationEval/__tests__/observationEvalProcessor.test.ts@@ -48,7 +48,7 @@ vi.mock("../../evalService", () => ({runLLMAsJudgeEvaluation: vi.fn(),}));-vi.mock("../../codeBased", () => ({+vi.mock("../../codeBased/executeCodeBasedEvaluation", () => ({executeCodeBasedEvaluation: vi.fn(),}));@@ -74,7 +74,7 @@ vi.mock("@langfuse/shared/src/server", async () => {});import { prisma } from "@langfuse/shared/src/db";-import { executeCodeBasedEvaluation } from "../../codeBased";+import { executeCodeBasedEvaluation } from "../../codeBased/executeCodeBasedEvaluation";import {createMockEvalExecutionDeps,type EvalExecutionDeps,diff --git a/worker/src/features/evaluation/observationEval/__tests__/scheduleObservationEvals.test.ts b/worker/src/features/evaluation/observationEval/__tests__/scheduleObservationEvals.test.tsindex 03fc3734d8..36eaa27371 100644--- a/worker/src/features/evaluation/observationEval/__tests__/scheduleObservationEvals.test.ts+++ b/worker/src/features/evaluation/observationEval/__tests__/scheduleObservationEvals.test.ts@@ -13,7 +13,7 @@ import {JobConfigState,JobExecutionStatus,} from "@langfuse/shared";-import { createW3CTraceId } from "../../../utils";+import { createW3CTraceId } from "../../../utils/utilities";describe("scheduleObservationEvals", () => {const createMockObservation = (diff --git a/worker/src/features/evaluation/observationEval/index.ts b/worker/src/features/evaluation/observationEval/index.tsdeleted file mode 100644index e6e4f9f1dd..0000000000--- a/worker/src/features/evaluation/observationEval/index.ts+++ /dev/null@@ -1,8 +0,0 @@-export {- isObservationAllowedForQueuedObservationEvals,- scheduleObservationEvals,-} from "./scheduleObservationEvals";-export { fetchObservationEvalRules } from "./fetchObservationEvalRules";-export { createObservationEvalSchedulerDeps } from "./createSchedulerDeps";-export { processObservationEval } from "./observationEvalProcessor";-export type { ObservationForEval, ObservationEvalRule } from "./types";diff --git a/worker/src/features/evaluation/observationEval/observationEvalProcessor.ts b/worker/src/features/evaluation/observationEval/observationEvalProcessor.tsindex 355ac7059e..a522d558a7 100644--- a/worker/src/features/evaluation/observationEval/observationEvalProcessor.ts+++ b/worker/src/features/evaluation/observationEval/observationEvalProcessor.ts@@ -6,6 +6,7 @@ import {extractObservationVariables,logger,recordIncrement,+ buildEvalExecutionData,} from "@langfuse/shared/src/server";import { isEvalTargetEnvironmentAllowed } from "../isEvalTargetEnvironmentAllowed";import {@@ -30,7 +31,7 @@ import {EvalFailureReason,UnrecoverableEvalFailureError,} from "../evalFailureErrors";-import { buildEvalExecutionData } from "@langfuse/shared/src/server";+import {completeEvalExecution,type EvalExecutionResult,@@ -40,7 +41,7 @@ import {type EvalExecutionDeps,} from "../evalExecutionDeps";import { runLLMAsJudgeEvaluation } from "../evalService";-import { executeCodeBasedEvaluation } from "../codeBased";+import { executeCodeBasedEvaluation } from "../codeBased/executeCodeBasedEvaluation";import { runDecisionModelEvaluation } from "../decisionModel/runDecisionModelEvaluation";import { getEvalS3StorageClient } from "../s3StorageClient";import { type ObservationForEval } from "./types";diff --git a/worker/src/features/evaluation/observationEval/scheduleObservationEvals.ts b/worker/src/features/evaluation/observationEval/scheduleObservationEvals.tsindex 585fee8edc..39cc7cbe5c 100644--- a/worker/src/features/evaluation/observationEval/scheduleObservationEvals.ts+++ b/worker/src/features/evaluation/observationEval/scheduleObservationEvals.ts@@ -1,4 +1,14 @@-import type { ObservationVariableMapping } from "@langfuse/shared";+import {+ type ObservationVariableMapping,+ EvalTemplateType,+ JobExecutionStatus,+ type FilterState,+ type EvalExecutionMode,+ canRunEvalRule,+ coerceLegacyEmptyMetadataFilters,+ mapEventEvalFilterColumnIdToField,+ observationVariableMappingList,+} from "@langfuse/shared";import {type ObservationForEval,type ObservationEvalAssignment,@@ -14,17 +24,8 @@ import {LangfuseInternalTraceEnvironment,logger,} from "@langfuse/shared/src/server";-import {- EvalTemplateType,- JobExecutionStatus,- type FilterState,- type EvalExecutionMode,- canRunEvalRule,- coerceLegacyEmptyMetadataFilters,- mapEventEvalFilterColumnIdToField,- observationVariableMappingList,-} from "@langfuse/shared";-import { createW3CTraceId } from "../../utils";++import { createW3CTraceId } from "../../utils/utilities";import { isInternalEvalEnvironment } from "../isEvalTargetEnvironmentAllowed";const OBSERVATION_FILTER_EMPTY_EQUALS_NULL_COLUMNS = new Set([diff --git a/worker/src/features/experiments/__tests__/scheduleExperimentEvals.test.ts b/worker/src/features/experiments/__tests__/scheduleExperimentEvals.test.tsindex 7b8521f902..f3bbad27ae 100644--- a/worker/src/features/experiments/__tests__/scheduleExperimentEvals.test.ts+++ b/worker/src/features/experiments/__tests__/scheduleExperimentEvals.test.ts@@ -8,7 +8,7 @@ import {materializeInternalTrace,} from "@langfuse/shared/src/server";import { prisma } from "@langfuse/shared/src/db";-import type { ObservationForEval } from "../../evaluation/observationEval";+import type { ObservationForEval } from "../../evaluation/observationEval/types";import { IngestionService } from "../../../services/IngestionService";import * as clickhouseWriterExports from "../../../services/ClickhouseWriter";import { scheduleExperimentObservationEvals } from "../scheduleExperimentEvals";@@ -37,15 +37,45 @@ vi.mock("../../../services/ClickhouseWriter", async (importOriginal) => {};});-vi.mock("../../evaluation/observationEval", async (importOriginal) => {- const original = (await importOriginal()) as object;- return {- ...original,- fetchObservationEvalRules: mockFetchObservationEvalRules,- createObservationEvalSchedulerDeps: mockCreateObservationEvalSchedulerDeps,- scheduleObservationEvals: mockScheduleObservationEvals,- };-});+vi.mock(+ "../../evaluation/observationEval/fetchObservationEvalRules",+ async (importOriginal) => {+ const original = (await importOriginal()) as object;+ return {+ ...original,+ fetchObservationEvalRules: mockFetchObservationEvalRules,+ createObservationEvalSchedulerDeps:+ mockCreateObservationEvalSchedulerDeps,+ scheduleObservationEvals: mockScheduleObservationEvals,+ };+ },+);+vi.mock(+ "../../evaluation/observationEval/createSchedulerDeps",+ async (importOriginal) => {+ const original = (await importOriginal()) as object;+ return {+ ...original,+ fetchObservationEvalRules: mockFetchObservationEvalRules,+ createObservationEvalSchedulerDeps:+ mockCreateObservationEvalSchedulerDeps,+ scheduleObservationEvals: mockScheduleObservationEvals,+ };+ },+);+vi.mock(+ "../../evaluation/observationEval/scheduleObservationEvals",+ async (importOriginal) => {+ const original = (await importOriginal()) as object;+ return {+ ...original,+ fetchObservationEvalRules: mockFetchObservationEvalRules,+ createObservationEvalSchedulerDeps:+ mockCreateObservationEvalSchedulerDeps,+ scheduleObservationEvals: mockScheduleObservationEvals,+ };+ },+);const mockClickhouseClient = {query: async () => ({diff --git a/worker/src/features/experiments/experimentServiceClickhouse.ts b/worker/src/features/experiments/experimentServiceClickhouse.tsindex 7d00500a89..21d646f98a 100644--- a/worker/src/features/experiments/experimentServiceClickhouse.ts+++ b/worker/src/features/experiments/experimentServiceClickhouse.ts@@ -4,6 +4,8 @@ import {convertEventRecordToObservationForEval,DatasetItemDomain,Prisma,+ validateDatasetItem,+ normalizeDatasetItemInput,} from "@langfuse/shared";import {ChatMessage,@@ -36,12 +38,9 @@ import {validateAndSetupExperiment,type PromptExperimentConfig,} from "./utils";-import {- validateDatasetItem,- normalizeDatasetItemInput,-} from "@langfuse/shared";+import { randomUUID } from "crypto";-import { createW3CTraceId } from "../utils";+import { createW3CTraceId } from "../utils/utilities";import { scheduleExperimentObservationEvals } from "./scheduleExperimentEvals";import { createInternalEventsWriter } from "../internal-tracing/createInternalEventsWriter";diff --git a/worker/src/features/experiments/scheduleExperimentEvals.ts b/worker/src/features/experiments/scheduleExperimentEvals.tsindex 7ebcd2595e..86ae0a6eac 100644--- a/worker/src/features/experiments/scheduleExperimentEvals.ts+++ b/worker/src/features/experiments/scheduleExperimentEvals.ts@@ -1,9 +1,7 @@-import {- fetchObservationEvalRules,- scheduleObservationEvals,- createObservationEvalSchedulerDeps,- type ObservationForEval,-} from "../evaluation/observationEval";+import { fetchObservationEvalRules } from "../evaluation/observationEval/fetchObservationEvalRules";+import { scheduleObservationEvals } from "../evaluation/observationEval/scheduleObservationEvals";+import { createObservationEvalSchedulerDeps } from "../evaluation/observationEval/createSchedulerDeps";+import type { ObservationForEval } from "../evaluation/observationEval/types";import { logger, traceException } from "@langfuse/shared/src/server";interface ScheduleExperimentEvalsParams {diff --git a/worker/src/features/in-app-agent/executeInAppAgentRun.ts b/worker/src/features/in-app-agent/executeInAppAgentRun.tsindex e9da1a8616..e0fe9bc971 100644--- a/worker/src/features/in-app-agent/executeInAppAgentRun.ts+++ b/worker/src/features/in-app-agent/executeInAppAgentRun.ts@@ -67,7 +67,7 @@ import {createInAppAgentSandboxProvider,getDefaultInAppAgentSandboxProviderType,} from "./runtime/sandbox/config";-import { createInAppAgentSandbox } from "./runtime/sandbox";+import { createInAppAgentSandbox } from "./runtime/sandbox/service";import { createAgUiStream } from "./runtime/agent";import { getInAppAgentPromptClient } from "./runtime/promptClient";import { loadInAppAgentSkills } from "./runtime/skills";diff --git a/worker/src/features/in-app-agent/runtime/agent.test.ts b/worker/src/features/in-app-agent/runtime/agent.test.tsindex 0a60dcac55..720c6d6ca3 100644--- a/worker/src/features/in-app-agent/runtime/agent.test.ts+++ b/worker/src/features/in-app-agent/runtime/agent.test.ts@@ -5,22 +5,20 @@ import { createSkill } from "@mastra/core/skills";import { MCPClient } from "@mastra/mcp";import { beforeEach, describe, expect, it, vi } from "vitest";-import type { AgUiEvent } from "@langfuse/shared/in-app-agent";import {+ type AgUiEvent,IN_APP_AGENT_MCP_TOOL_OVERRIDE_HEADER,IN_APP_AGENT_REDIRECT_TOOL_NAME,IN_APP_AGENT_TOOL_APPROVAL_EVENT_NAME,IN_APP_AGENT_TOOL_REJECTION_ERROR_CODE,} from "@langfuse/shared/in-app-agent";+import { createInAppAgentToolPolicy } from "@langfuse/shared/in-app-agent/server/mcpPolicy";import { IN_APP_AGENT_MAX_STEPS } from "@langfuse/shared/in-app-agent/server/tunables";import { patchMastraApprovalChunks, type createAgUiStream } from "./agent";import { loadInAppAgentSkills } from "./skills";-import {- createInAppAgentSandbox,- type SandboxProvider,- type SandboxSession,-} from "./sandbox";+import { createInAppAgentSandbox } from "./sandbox/service";+import type { SandboxProvider, SandboxSession } from "./sandbox/types";import {DEFAULT_SIDEBAR_HIDDEN_ENVIRONMENTS,decodeFiltersGeneric,diff --git a/worker/src/features/in-app-agent/runtime/agent.ts b/worker/src/features/in-app-agent/runtime/agent.tsindex b99b5ae2df..308b0b3a3b 100644--- a/worker/src/features/in-app-agent/runtime/agent.ts+++ b/worker/src/features/in-app-agent/runtime/agent.ts@@ -17,6 +17,9 @@ import type { Langfuse } from "langfuse";import {type AgUiEvent,type InAppAgentToolApprovalRequest,+ IN_APP_AGENT_MCP_TOOL_OVERRIDE_HEADER,+ IN_APP_AGENT_QUESTIONNAIRE_TOOL_NAME,+ IN_APP_AGENT_REDIRECT_TOOL_NAME,} from "@langfuse/shared/in-app-agent";import { getToolFailureMessage } from "@langfuse/shared/in-app-agent/server/toolErrors";import { IN_APP_AGENT_MAX_STEPS } from "@langfuse/shared/in-app-agent/server/tunables";@@ -25,11 +28,12 @@ import {createManualToolApprovalRunInput,type ManualToolApprovalResumeData,} from "./human-in-the-loop";-import type {- InAppAgentPromptMetadata,- InAppAgentTracingConfig,+import {+ type InAppAgentPromptMetadata,+ type InAppAgentTracingConfig,+ createInAppAgentInstrumentation,} from "./instrumentation";-import { createInAppAgentInstrumentation } from "./instrumentation";+import {parseMcpRateLimitError,withMcpRateLimitWait,@@ -55,14 +59,10 @@ import {withInAppAgentToolApproval,withInAppAgentToolApprovalSidecars,} from "@langfuse/shared/in-app-agent/server/mcpPolicy";-import type { InAppAgentSandbox } from "./sandbox";+import type { InAppAgentSandbox } from "./sandbox/types";import { DEFAULT_SIDEBAR_HIDDEN_ENVIRONMENTS } from "@langfuse/shared";import { logger } from "@langfuse/shared/src/server";-import {- IN_APP_AGENT_MCP_TOOL_OVERRIDE_HEADER,- IN_APP_AGENT_QUESTIONNAIRE_TOOL_NAME,- IN_APP_AGENT_REDIRECT_TOOL_NAME,-} from "@langfuse/shared/in-app-agent";+import type { InAppAgentModelConfig } from "@langfuse/shared/in-app-agent/server/modelProvider";import { applyPromptCacheToCall } from "./promptCache";import {diff --git a/worker/src/features/in-app-agent/runtime/sandbox/index.ts b/worker/src/features/in-app-agent/runtime/sandbox/index.tsdeleted file mode 100644index cdc002154d..0000000000--- a/worker/src/features/in-app-agent/runtime/sandbox/index.ts+++ /dev/null@@ -1,6 +0,0 @@-export { createInAppAgentSandbox } from "./service";-export type {- InAppAgentSandbox,- SandboxProvider,- SandboxSession,-} from "./types";diff --git a/worker/src/features/in-app-agent/runtime/sandbox/sandbox.test.ts b/worker/src/features/in-app-agent/runtime/sandbox/sandbox.test.tsindex 83c2abbe4e..2ccf273a2e 100644--- a/worker/src/features/in-app-agent/runtime/sandbox/sandbox.test.ts+++ b/worker/src/features/in-app-agent/runtime/sandbox/sandbox.test.ts@@ -8,7 +8,7 @@ import { describe, expect, it } from "vitest";import { z } from "zod";import { createSandboxToolCallFileAccumulator } from "@langfuse/shared/in-app-agent/server/persistence";-import { createInAppAgentSandbox } from ".";+import { createInAppAgentSandbox } from "./service";import { withOptionalSilentMcpOutput } from "../tools";// Only presence matters for the tests below: it is what makesdiff --git a/worker/src/features/in-app-agent/runtime/tools.ts b/worker/src/features/in-app-agent/runtime/tools.tsindex 3cd14219bd..a3af90db99 100644--- a/worker/src/features/in-app-agent/runtime/tools.ts+++ b/worker/src/features/in-app-agent/runtime/tools.ts@@ -3,8 +3,14 @@ import {toStandardSchema,} from "@mastra/core/schema";import { createTool, Tool } from "@mastra/core/tools";-import type { InAppAgentSandbox } from "./sandbox";-import { isoDateTime, assertUnreachable } from "@langfuse/shared";+import type { InAppAgentSandbox } from "./sandbox/types";+import {+ isoDateTime,+ assertUnreachable,+ ObservationLevelDomain,+ TABLE_AGGREGATION_OPTIONS,+ TracingSearchType,+} from "@langfuse/shared";import { getToolFailureMessage } from "@langfuse/shared/in-app-agent/server/toolErrors";import {buildDashboardsPath,@@ -25,11 +31,7 @@ import {buildTracesPath,} from "@langfuse/shared/src/server";import z from "zod";-import {- ObservationLevelDomain,- TABLE_AGGREGATION_OPTIONS,- TracingSearchType,-} from "@langfuse/shared";+import {InAppAgentSandboxBashArgsSchema,InAppAgentSandboxEditArgsSchema,diff --git a/worker/src/features/otel-ingestion/processOtelEvents.ts b/worker/src/features/otel-ingestion/processOtelEvents.tsindex 46a55e0495..6b26ec2df5 100644--- a/worker/src/features/otel-ingestion/processOtelEvents.ts+++ b/worker/src/features/otel-ingestion/processOtelEvents.ts@@ -7,12 +7,12 @@ import {traceException,} from "@langfuse/shared/src/server";import { env } from "../../env";+import { fetchObservationEvalRules } from "../evaluation/observationEval/fetchObservationEvalRules";import {- fetchObservationEvalRules,isObservationAllowedForQueuedObservationEvals,scheduleObservationEvals,- createObservationEvalSchedulerDeps,-} from "../evaluation/observationEval";+} from "../evaluation/observationEval/scheduleObservationEvals";+import { createObservationEvalSchedulerDeps } from "../evaluation/observationEval/createSchedulerDeps";import { trackTraceBatchActivity } from "../traceBatching/traceBatching";import {createDirectOtelMediaTargets,diff --git a/worker/src/features/utils/index.ts b/worker/src/features/utils/index.tsdeleted file mode 100644index 5d1926aa63..0000000000--- a/worker/src/features/utils/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./utilities";-export * from "./retry-handler";diff --git a/worker/src/queues/__tests__/codeEvalExecutionQueueProcessor.test.ts b/worker/src/queues/__tests__/codeEvalExecutionQueueProcessor.test.tsindex 4222dd034c..d1487a96ac 100644--- a/worker/src/queues/__tests__/codeEvalExecutionQueueProcessor.test.ts+++ b/worker/src/queues/__tests__/codeEvalExecutionQueueProcessor.test.ts@@ -9,7 +9,10 @@ import {} from "vitest";import { Job } from "bullmq";import { EvalTemplateType } from "@prisma/client";-import { UnrecoverableError } from "../../errors/UnrecoverableError";+import {+ UnrecoverableError,+ isUnrecoverableError,+} from "../../errors/UnrecoverableError";const QueueName = {CodeEvalExecution: "code-eval-execution-queue",@@ -27,13 +30,19 @@ vi.mock("@langfuse/shared/src/db", () => ({},}));-vi.mock("../../features/evaluation/observationEval", () => ({- processObservationEval: vi.fn(),-}));+vi.mock(+ "../../features/evaluation/observationEval/observationEvalProcessor",+ () => ({+ processObservationEval: vi.fn(),+ }),+);-vi.mock("../../features/evaluation/codeBased", () => ({- executeCodeBasedEvaluation: vi.fn(),-}));+vi.mock(+ "../../features/evaluation/codeBased/executeCodeBasedEvaluation",+ () => ({+ executeCodeBasedEvaluation: vi.fn(),+ }),+);vi.mock("@langfuse/shared/src/server", async (importOriginal) => {const actual =@@ -60,7 +69,7 @@ vi.mock("@langfuse/shared/src/server", async (importOriginal) => {};});-vi.mock("../../features/utils", () => ({+vi.mock("../../features/utils/utilities", () => ({createW3CTraceId: vi.fn().mockReturnValue("test-trace-id"),}));@@ -73,7 +82,7 @@ vi.mock("../../errors/UnrecoverableError", async () => {});import { prisma } from "@langfuse/shared/src/db";-import { processObservationEval } from "../../features/evaluation/observationEval";+import { processObservationEval } from "../../features/evaluation/observationEval/observationEvalProcessor";import {recordDistribution,recordIncrement,@@ -81,7 +90,6 @@ import {} from "@langfuse/shared/src/server";import { CodeEvalDispatcherErrorCodes } from "../../../../packages/shared/src/server/evals/codeEvalDispatcherTypes";import { CodeEvalExecutionError } from "../../../../packages/shared/src/server/evals/codeEvalExecution";-import { isUnrecoverableError } from "../../errors/UnrecoverableError";describe("codeEvalExecutionQueueProcessor", () => {const projectId = "test-project-123";diff --git a/worker/src/queues/__tests__/experimentQueueProcessor.test.ts b/worker/src/queues/__tests__/experimentQueueProcessor.test.tsindex edce4146cd..3db356ae41 100644--- a/worker/src/queues/__tests__/experimentQueueProcessor.test.ts+++ b/worker/src/queues/__tests__/experimentQueueProcessor.test.ts@@ -20,7 +20,7 @@ vi.mock("@langfuse/shared/src/server", () => ({traceException: vi.fn(),}));-vi.mock("../../features/utils", () => ({+vi.mock("../../features/utils/retry-handler", () => ({retryLLMRateLimitError: vi.fn(),}));@@ -38,7 +38,7 @@ vi.mock("../../errors/UnrecoverableError", async () => {import { classifyEvaluatorLlmError } from "@langfuse/shared/src/server";import { createExperimentJobClickhouse } from "../../features/experiments/experimentServiceClickhouse";-import { retryLLMRateLimitError } from "../../features/utils";+import { retryLLMRateLimitError } from "../../features/utils/retry-handler";import { experimentCreateQueueProcessor } from "../experimentQueue";import { isUnrecoverableError } from "../../errors/UnrecoverableError";diff --git a/worker/src/queues/__tests__/llmAsJudgeExecutionQueueProcessor.test.ts b/worker/src/queues/__tests__/llmAsJudgeExecutionQueueProcessor.test.tsindex 4a3b32f51d..cc63836ed5 100644--- a/worker/src/queues/__tests__/llmAsJudgeExecutionQueueProcessor.test.ts+++ b/worker/src/queues/__tests__/llmAsJudgeExecutionQueueProcessor.test.ts@@ -8,7 +8,10 @@ import {type Mock,} from "vitest";import { Job } from "bullmq";-import { UnrecoverableError } from "../../errors/UnrecoverableError";+import {+ UnrecoverableError,+ isUnrecoverableError,+} from "../../errors/UnrecoverableError";import {EvalFailureError,EvalFailureReason,@@ -51,9 +54,12 @@ vi.mock("@langfuse/shared/src/db", () => ({}));// Mock processObservationEval-vi.mock("../../features/evaluation/observationEval", () => ({- processObservationEval: vi.fn(),-}));+vi.mock(+ "../../features/evaluation/observationEval/observationEvalProcessor",+ () => ({+ processObservationEval: vi.fn(),+ }),+);// Mock logger and spanvi.mock("@langfuse/shared/src/server", async () => {@@ -102,7 +108,11 @@ vi.mock("@langfuse/shared/src/server", async () => {});// Mock retryLLMRateLimitError-vi.mock("../../features/utils", () => ({+vi.mock("../../features/utils/utilities", () => ({+ createW3CTraceId: vi.fn().mockReturnValue("test-trace-id"),+ retryLLMRateLimitError: vi.fn(),+}));+vi.mock("../../features/utils/retry-handler", () => ({createW3CTraceId: vi.fn().mockReturnValue("test-trace-id"),retryLLMRateLimitError: vi.fn(),}));@@ -117,7 +127,7 @@ vi.mock("../../errors/UnrecoverableError", async () => {});import { prisma } from "@langfuse/shared/src/db";-import { processObservationEval } from "../../features/evaluation/observationEval";+import { processObservationEval } from "../../features/evaluation/observationEval/observationEvalProcessor";import {LLMAsJudgeExecutionQueue,classifyEvaluatorLlmError,@@ -126,8 +136,7 @@ import {recordIncrement,traceException,} from "@langfuse/shared/src/server";-import { retryLLMRateLimitError } from "../../features/utils";-import { isUnrecoverableError } from "../../errors/UnrecoverableError";+import { retryLLMRateLimitError } from "../../features/utils/retry-handler";function mockLlmError(error: Error, isRetryable: boolean): void {vi.mocked(classifyEvaluatorLlmError).mockReturnValue({@@ -664,7 +673,8 @@ describe("llmAsJudgeExecutionQueueProcessor", () => {(processObservationEval as Mock).mockRejectedValue(error);vi.mocked(isUnrecoverableError).mockReturnValue(true);- const { createW3CTraceId } = await import("../../features/utils");+ const { createW3CTraceId } =+ await import("../../features/utils/utilities");const job = createMockJob();await llmAsJudgeExecutionQueueProcessor(job);diff --git a/worker/src/queues/__tests__/otelDirectEventWrite.test.ts b/worker/src/queues/__tests__/otelDirectEventWrite.test.tsindex 4197b84787..ce215a89ba 100644--- a/worker/src/queues/__tests__/otelDirectEventWrite.test.ts+++ b/worker/src/queues/__tests__/otelDirectEventWrite.test.ts@@ -14,7 +14,7 @@ import * as otelPreparation from "../../features/otel-ingestion/prepareOtelBatchimport * as mediaRestoration from "../../features/otel-media/resolveExtractedMedia";import { IngestionService } from "../../services/IngestionService";import { ClickhouseWriter } from "../../services/ClickhouseWriter";-import { fetchObservationEvalRules } from "../../features/evaluation/observationEval";+import { fetchObservationEvalRules } from "../../features/evaluation/observationEval/fetchObservationEvalRules";import { trackTraceBatchActivity } from "../../features/traceBatching/traceBatching";import {batchContainsLangfuseScope,@@ -35,10 +35,10 @@ vi.mock("@langfuse/shared/src/server", async (importOriginal) => ({markProjectIngestFailure: vi.fn(),}));vi.mock(- "../../features/evaluation/observationEval",+ "../../features/evaluation/observationEval/fetchObservationEvalRules",async (importOriginal) => ({...(await importOriginal<- typeof import("../../features/evaluation/observationEval")+ typeof import("../../features/evaluation/observationEval/fetchObservationEvalRules")>()),fetchObservationEvalRules: vi.fn(),}),diff --git a/worker/src/queues/codeEvalQueue.ts b/worker/src/queues/codeEvalQueue.tsindex 75bb85d31a..bd52cfa584 100644--- a/worker/src/queues/codeEvalQueue.ts+++ b/worker/src/queues/codeEvalQueue.ts@@ -10,8 +10,8 @@ import {TQueueJobTypes,traceException,} from "@langfuse/shared/src/server";-import { processObservationEval } from "../features/evaluation/observationEval";-import { createW3CTraceId } from "../features/utils";+import { processObservationEval } from "../features/evaluation/observationEval/observationEvalProcessor";+import { createW3CTraceId } from "../features/utils/utilities";import { isUnrecoverableError } from "../errors/UnrecoverableError";import {getCodeEvalTerminalErrorOutcome,diff --git a/worker/src/queues/evalQueue.ts b/worker/src/queues/evalQueue.tsindex f881390e8c..377171e10e 100644--- a/worker/src/queues/evalQueue.ts+++ b/worker/src/queues/evalQueue.ts@@ -15,8 +15,9 @@ import {type EvaluatorLlmErrorClassification,} from "@langfuse/shared/src/server";import { createEvalJobs, evaluate } from "../features/evaluation/evalService";-import { processObservationEval } from "../features/evaluation/observationEval";-import { createW3CTraceId, retryLLMRateLimitError } from "../features/utils";+import { processObservationEval } from "../features/evaluation/observationEval/observationEvalProcessor";+import { createW3CTraceId } from "../features/utils/utilities";+import { retryLLMRateLimitError } from "../features/utils/retry-handler";import { isUnrecoverableError } from "../errors/UnrecoverableError";import { retryObservationNotFound } from "../features/evaluation/retryObservationNotFound";import { isObservationNotFoundError } from "../errors/ObservationNotFoundError";diff --git a/worker/src/queues/experimentQueue.ts b/worker/src/queues/experimentQueue.tsindex 412fb41630..88d65573eb 100644--- a/worker/src/queues/experimentQueue.ts+++ b/worker/src/queues/experimentQueue.ts@@ -8,7 +8,7 @@ import {logger,traceException,} from "@langfuse/shared/src/server";-import { retryLLMRateLimitError } from "../features/utils";+import { retryLLMRateLimitError } from "../features/utils/retry-handler";import { createExperimentJobClickhouse } from "../features/experiments/experimentServiceClickhouse";import { isUnrecoverableError } from "../errors/UnrecoverableError";diff --git a/worker/src/utils/clickhouseIdentifiers.ts b/worker/src/utils/clickhouseIdentifiers.tsdeleted file mode 100644index 0467bda9f8..0000000000--- a/worker/src/utils/clickhouseIdentifiers.ts+++ /dev/null@@ -1,6 +0,0 @@-export {- assertClickhouseIdentifier,- qualifiedClickhouseTableName,- quoteClickhouseIdentifier,- quoteClickhouseString,-} from "@langfuse/shared/src/server/clickhouse/clickhouseIdentifiers";