Skip to content

Commit 33fe830

Browse files
authored
ref(plugin-api)!: standardize source visibility (#1183)
## Summary - replace `Source.type: "pub" | "priv"` with `Source.visibility: "public" | "private"` - hard-cut runtime, plugin, scheduler, memory, test, and eval consumers to the canonical vocabulary - migrate persisted conversation `source_json` records to the new field and values This PR is stacked on #1182 and should be retargeted to `main` after that PR merges. ## Breaking change Plugin authors must update source construction and reads from `type`/`pub`/`priv` to `visibility`/`public`/`private`. There is no compatibility reader; durable conversation records are upgraded by the included SQL migration. ## Testing - `pnpm typecheck` - `pnpm --filter @sentry/junior exec vitest run tests/unit/plugin-api-source.test.ts tests/unit/runtime/source.test.ts tests/unit/plugins/agent-hooks.test.ts tests/integration/heartbeat.test.ts tests/integration/slack-schedule-tools.test.ts tests/integration/conversation-sql.test.ts` (118 tests) - `pnpm --filter @sentry/junior-memory test` (89 tests) - `pnpm --filter @sentry/junior-github exec vitest run tests/github-plugin.test.ts` (73 tests) - `pnpm --filter @sentry/junior-plugin-api build` - `pnpm --filter @sentry/junior-scheduler build` - `pnpm lint` passed all source and architecture checks; the final `publint` packaging step failed locally because it could not find pnpm's tarball despite `pnpm pack` exiting successfully
1 parent 6fa2946 commit 33fe830

57 files changed

Lines changed: 1352 additions & 119 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/junior-evals/evals/memory/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function seedMemory(args: {
4343
messageTs: args.thread.thread_ts,
4444
teamId: memoryTeamId,
4545
threadTs: args.thread.thread_ts,
46-
type: args.thread.channel_type === "channel" ? "pub" : "priv",
46+
visibility: args.thread.channel_type === "channel" ? "public" : "private",
4747
}),
4848
});
4949
const input = {

packages/junior-evals/evals/memory/personal.eval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ describeEval("Personal Memory", slackEvals, (it) => {
196196
teamId: memoryTeamId,
197197
threadTs: "17000000.000003",
198198

199-
type: "priv",
199+
visibility: "private",
200200
}),
201201
};
202202

packages/junior-github/tests/github-plugin.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ function githubToolsContext(input?: {
324324
destination: { platform: "local" as const, conversationId },
325325
source: {
326326
platform: "local" as const,
327-
type: "priv" as const,
327+
visibility: "private" as const,
328328
conversationId,
329329
},
330330
embedder: {},

packages/junior-memory/src/personal.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function runtimeContext(actor: PluginUserPageActor): MemoryRuntimeContext {
5757
actor,
5858
source: {
5959
platform: "slack",
60-
type: "priv",
60+
visibility: "private",
6161
teamId: actor.teamId,
6262
channelId: "DDASHBOARD",
6363
},
@@ -67,15 +67,18 @@ function runtimeContext(actor: PluginUserPageActor): MemoryRuntimeContext {
6767
actor,
6868
source: {
6969
platform: "local",
70-
type: "priv",
70+
visibility: "private",
7171
conversationId: "local:dashboard:memories",
7272
},
7373
};
7474
}
7575

7676
function decodeCursor(
7777
value: string | undefined,
78-
input: Pick<ViewerMemoryPageInput, "kind" | "origin" | "query" | "visibility">,
78+
input: Pick<
79+
ViewerMemoryPageInput,
80+
"kind" | "origin" | "query" | "visibility"
81+
>,
7982
) {
8083
if (!value) return undefined;
8184
try {
@@ -98,7 +101,10 @@ function decodeCursor(
98101

99102
function encodeCursor(
100103
cursor: { createdAtMs: number; id: string },
101-
input: Pick<ViewerMemoryPageInput, "kind" | "origin" | "query" | "visibility">,
104+
input: Pick<
105+
ViewerMemoryPageInput,
106+
"kind" | "origin" | "query" | "visibility"
107+
>,
102108
): string {
103109
return Buffer.from(
104110
JSON.stringify({

packages/junior-memory/tests/retrieval-quality.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function runtimeContext() {
7474
messageTs: threadTs,
7575
teamId,
7676
threadTs,
77-
type: "pub",
77+
visibility: "public",
7878
}),
7979
};
8080
}

packages/junior-memory/tests/storage.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function slackContext(
371371
channelId,
372372
// The Slack boundary supplies normalized public visibility for these
373373
// C-prefixed test channels unless a test overrides the channel id.
374-
type: channelId.startsWith("C") ? "pub" : "priv",
374+
visibility: channelId.startsWith("C") ? "public" : "private",
375375
messageTs: threadTs,
376376
threadTs,
377377
}),
@@ -1602,7 +1602,7 @@ describe("memory plugin storage", () => {
16021602
teamId: runtime.source.teamId,
16031603
channelId: runtime.source.channelId,
16041604

1605-
type: "priv",
1605+
visibility: "private",
16061606
}),
16071607
});
16081608
},
@@ -3547,7 +3547,7 @@ WHERE id = '${superseded.memory.id}'
35473547
},
35483548
source: {
35493549
platform: "slack",
3550-
type: "pub",
3550+
visibility: "public",
35513551
teamId: "T123",
35523552
channelId: "C123",
35533553
messageTs: "1718800000.000000",

packages/junior-plugin-api/src/context.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type SystemActor = z.output<typeof systemActorSchema>;
1919
export type Source = z.output<typeof sourceSchema>;
2020
export type SlackSource = Extract<Source, { platform: "slack" }>;
2121
export type LocalSource = Extract<Source, { platform: "local" }>;
22-
export type SourceType = Source["type"];
22+
export type SourceVisibility = Source["visibility"];
2323

2424
export type Destination = z.output<typeof destinationSchema>;
2525

@@ -103,11 +103,11 @@ export function createSlackSource(input: {
103103
teamId: string;
104104
threadTs?: string;
105105
/** Runtime-normalized source visibility. */
106-
type: SourceType;
106+
visibility: SourceVisibility;
107107
}): SlackSource {
108108
return {
109109
platform: "slack",
110-
type: input.type,
110+
visibility: input.visibility,
111111
teamId: input.teamId,
112112
channelId: input.channelId,
113113
...(input.messageTs ? { messageTs: input.messageTs } : {}),
@@ -119,14 +119,14 @@ export function createSlackSource(input: {
119119
export function createLocalSource(conversationId: string): LocalSource {
120120
return {
121121
platform: "local",
122-
type: "priv",
122+
visibility: "private",
123123
conversationId,
124124
};
125125
}
126126

127127
/** Return whether a source is private to a person or restricted group. */
128128
export function isPrivateSource(source: Source): boolean {
129-
return source.type === "priv";
129+
return source.visibility === "private";
130130
}
131131

132132
/** Return the stable source identity used for idempotency and attribution. */

packages/junior-plugin-api/src/schemas.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const exactNonBlankStringSchema = nonBlankStringSchema.refine(
2323
export const platformSchema = z.enum(["slack", "local"]);
2424

2525
/** Runtime source visibility visible to plugins. */
26-
export const sourceTypeSchema = z.enum(["pub", "priv"]);
26+
export const sourceVisibilitySchema = z.enum(["public", "private"]);
2727

2828
/** Provider-neutral visibility of a routed destination. */
2929
export const destinationVisibilitySchema = z.enum(["public", "private"]);
@@ -56,7 +56,7 @@ export const destinationSchema = z.discriminatedUnion("platform", [
5656
/** Runtime-owned Slack coordinates for the inbound invocation. */
5757
export const slackSourceSchema = slackAddressSchema
5858
.extend({
59-
type: sourceTypeSchema,
59+
visibility: sourceVisibilitySchema,
6060
messageTs: nonBlankStringSchema.optional(),
6161
threadTs: nonBlankStringSchema.optional(),
6262
})
@@ -66,7 +66,7 @@ export const slackSourceSchema = slackAddressSchema
6666
export const localSourceSchema = z
6767
.object({
6868
platform: z.literal("local"),
69-
type: z.literal("priv"),
69+
visibility: z.literal("private"),
7070
conversationId: localConversationIdSchema,
7171
})
7272
.strict();

packages/junior-scheduler/src/plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ function scheduledTaskDispatchSource(task: ScheduledTask): Source {
8181
return createSlackSource({
8282
teamId: task.destination.teamId,
8383
channelId: task.destination.channelId,
84-
type: task.conversationAccess?.visibility === "public" ? "pub" : "priv",
84+
visibility:
85+
task.conversationAccess?.visibility === "public" ? "public" : "private",
8586
});
8687
}
8788

packages/junior-scheduler/src/tool-support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export function getConversationAccess(
164164
}
165165
return {
166166
audience: "channel",
167-
visibility: source?.type === "pub" ? "public" : "private",
167+
visibility: source?.visibility === "public" ? "public" : "private",
168168
};
169169
}
170170

0 commit comments

Comments
 (0)