Skip to content

Commit bafa715

Browse files
ref: Remove unused exports (#3579)
This deletes code that nothing uses and makes helpers private when only their own file uses them. **Before:** 34 exports that nothing outside their file used were still exported or kept around, for example `parseActor`, `buildSentryTraceUrl`, `recordAuthenticationUnlinked` and `getProductionConversationStore`. **After:** 21 of them are deleted, along with the unused `db/schema/vector.ts`, and the other 13 are private to their file. The reader for old `authentication_unlinked` events stays. Possible follow-up, left out because third-party plugins use them: `isPrivateSource` and `experimental_context` in `@sentry/junior-plugin-api`, and the `./testing` subpath exports of `@sentry/junior-sentry` and `@sentry/junior-vercel`. <!-- junior-request-attribution:start --> via @MathurAditya724. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Ac214e596bfdca9c4d3127c855c2f3d2a --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Ac214e596bfdca9c4d3127c855c2f3d2a) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ac214e596bfdca9c4d3127c855c2f3d2a/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Aditya Mathur <[email protected]>
1 parent 0993536 commit bafa715

27 files changed

Lines changed: 31 additions & 273 deletions

File tree

‎packages/junior-memory/src/types.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export type MemoryScope = (typeof MEMORY_SCOPES)[number];
2626
export type MemorySubjectType = (typeof MEMORY_SUBJECT_TYPES)[number];
2727
export type MemorySourcePlatform = (typeof MEMORY_SOURCE_PLATFORMS)[number];
2828
export type MemoryEmbeddingMetric = (typeof MEMORY_EMBEDDING_METRICS)[number];
29-
export type MemoryEmbeddingDimensions =
30-
(typeof MEMORY_EMBEDDING_DIMENSIONS)[number];
3129
export type MemorySignal = (typeof MEMORY_SIGNALS)[number];
3230

3331
const nonEmptyStringSchema = z.string().min(1);

‎packages/junior/src/api/conversations/aggregate.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,3 @@ export function conversationRangeColumns() {
111111
),
112112
};
113113
}
114-
115-
/** Count distinct UTC activity dates without loading conversation timestamps into the app. */
116-
export function conversationActiveDaysColumn() {
117-
return sql<number>`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
118-
}

‎packages/junior/src/api/conversations/reporting.ts‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ export type ReportingConversationRow = {
3131
usage: (typeof juniorConversations.$inferSelect)["usage"];
3232
};
3333

34-
/** Parse report timestamps without throwing on malformed legacy values. */
35-
export function reportTime(value: string): number | undefined {
36-
const time = Date.parse(value);
37-
return Number.isFinite(time) ? time : undefined;
38-
}
39-
40-
/** Convert a report timestamp into the UTC day used by activity projections. */
41-
export function reportDate(value: string): string | undefined {
42-
const time = reportTime(value);
43-
return time === undefined
44-
? undefined
45-
: new Date(time).toISOString().slice(0, 10);
46-
}
47-
4834
/** Return the dashboard label for a conversation surface. */
4935
export function surfaceLabel(surface: ConversationSurface): string {
5036
if (surface === "scheduler") return "Scheduler";
@@ -140,29 +126,3 @@ export function summaryFromRow(
140126
usage: options.metrics?.usage ?? row.usage ?? undefined,
141127
});
142128
}
143-
144-
/** Collapse persisted conversation usage into the dashboard token total. */
145-
export function usageTokens(
146-
row: Pick<ReportingConversationRow, "usage">,
147-
): number | undefined {
148-
const usage = row.usage;
149-
if (!usage) return undefined;
150-
if (usage.totalTokens !== undefined) return usage.totalTokens;
151-
const values = [
152-
usage.inputTokens,
153-
usage.outputTokens,
154-
usage.cachedInputTokens,
155-
usage.cacheCreationTokens,
156-
].filter((value): value is number => value !== undefined);
157-
return values.length
158-
? values.reduce((sum, value) => sum + value, 0)
159-
: undefined;
160-
}
161-
162-
/** Collapse a conversation summary status into aggregate counters. */
163-
export function conversationSignals(summary: ConversationSummaryReport) {
164-
return {
165-
active: summary.status === "active",
166-
failed: summary.status === "failed",
167-
};
168-
}

‎packages/junior/src/api/reporting-window.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,3 @@ export function sumUtcHoursIntoSixHours<T extends { date: string }>(args: {
174174
rows: bySix,
175175
});
176176
}
177-
178-
/** PostgreSQL TO_CHAR pattern for UTC day keys. */
179-
export const PG_UTC_DAY = "YYYY-MM-DD";
180-
181-
/** PostgreSQL TO_CHAR pattern for UTC hour keys. */
182-
export const PG_UTC_HOUR = 'YYYY-MM-DD"T"HH24';

‎packages/junior/src/chat/actor.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* remains explicit so durable conversation metadata is not repaired on read.
66
*/
77
import * as z from "zod";
8-
import { actorSchema } from "@sentry/junior-plugin-api";
98
import { parseSlackTeamId } from "@/chat/slack/ids";
109

1110
const SLACK_USER_ID_DISPLAY_PATTERN = /^[UW][A-Z0-9]{5,}$/;
@@ -63,12 +62,6 @@ export interface SlackActorProfile {
6362

6463
export type StoredSlackActor = z.output<typeof storedSlackActorSchema>;
6564

66-
/** Parse a serialized runtime actor that crossed a durable boundary. */
67-
export function parseActor(value: unknown): Actor | undefined {
68-
const result = actorSchema.safeParse(value);
69-
return result.success ? result.data : undefined;
70-
}
71-
7265
/** Return whether an actor is a platform-scoped user actor. */
7366
export function isUserActor(actor: Actor | undefined): actor is UserActor {
7467
return Boolean(actor && "userId" in actor);

‎packages/junior/src/chat/agent-dispatch/heartbeat.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function runWithTimeout<T>(
6666
}
6767

6868
/** Run plugin heartbeat hooks with bounded per-invocation work. */
69-
export async function runPluginHeartbeats(args: {
69+
async function runPluginHeartbeats(args: {
7070
conversationWorkQueue: ConversationWorkQueue;
7171
dispatchForIdentity: IdentityDispatcher;
7272
events: AppEventPublisher;

‎packages/junior/src/chat/agent-invocations/fork-history.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const FORK_INSTRUCTIONS =
1616
* result. A model request with an unanswered tool call fails, and the parent
1717
* can commit its history in the middle of a tool round.
1818
*/
19-
export function forkHistoryFrom(
19+
function forkHistoryFrom(
2020
messages: readonly PiMessage[],
2121
parentToolCallId: string | undefined,
2222
): PiMessage[] {

‎packages/junior/src/chat/app/production.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { createJuniorSlackAdapter } from "@/chat/slack/adapter";
1313
import type { SlackWebhookServices } from "@/chat/ingress/slack-webhook";
1414
import type { JuniorRuntimeServiceOverrides } from "@/chat/app/services";
1515
import { getConversationStore } from "@/chat/db";
16-
import type { ConversationStore } from "@/chat/conversations/store";
1716
import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
1817
import {
1918
createConversationWork,
@@ -49,17 +48,12 @@ export function getProductionSlackAdapter(): SlackAdapter {
4948
return productionSlackAdapter;
5049
}
5150

52-
/** Return the production conversation store for current config. */
53-
export function getProductionConversationStore(): ConversationStore {
54-
return getConversationStore();
55-
}
56-
5751
/** Create production-backed services for Slack webhook ingress. */
5852
export function createProductionSlackWebhookServices(options: {
5953
queue: ConversationWorkQueue;
6054
services?: JuniorRuntimeServiceOverrides;
6155
}): SlackWebhookServices {
62-
const conversationStore = getProductionConversationStore();
56+
const conversationStore = getConversationStore();
6357
const runtime = createSlackRuntime({
6458
getSlackAdapter: getProductionSlackAdapter,
6559
// Webhook ingress only starts and refreshes assistant threads. Turns run
@@ -84,7 +78,7 @@ export function createProductionConversationWorkOptions(options: {
8478
services?: JuniorRuntimeServiceOverrides;
8579
waitUntil: (task: Promise<unknown>) => void;
8680
}): ConversationWorkCallbackOptions {
87-
const conversationStore = getProductionConversationStore();
81+
const conversationStore = getConversationStore();
8882
return createConversationWork({
8983
agentRunner: options.agentRunner,
9084
conversationStore,

‎packages/junior/src/chat/config.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,6 @@ export function getSlackClientSecret(): string | undefined {
664664
return chatConfig.slack.clientSecret;
665665
}
666666

667-
export function hasRedisConfig(): boolean {
668-
return Boolean(chatConfig.state.redisUrl);
669-
}
670-
671667
// ---------------------------------------------------------------------------
672668
// Runtime metadata
673669
// ---------------------------------------------------------------------------

‎packages/junior/src/chat/conversations/event-lexemes.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818

1919
// Characters of one event that keyword search and excerpts read. The
2020
// tsvector of this much text stays far below the 1 MB Postgres limit.
21-
export const MAX_SEARCHED_EVENT_CHARS = 200_000;
21+
const MAX_SEARCHED_EVENT_CHARS = 200_000;
2222
// A run takes about 4 s on a local Postgres 17 for events of 5 KB each. A
2323
// long Conversation catches up over later Turns.
2424
const MAX_EVENTS_PER_RUN = 2_000;

0 commit comments

Comments
 (0)