Skip to content

Commit 6c31ca7

Browse files
refactor: keep Tailcat and federation helpers module-private
CI's Knip export check covers apps/server and apps/desktop and flags exports used only inside their own module. Drop those exports and mark the service constructors @public, the same convention the rest of the server and desktop use. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent d671cc9 commit 6c31ca7

10 files changed

Lines changed: 28 additions & 26 deletions

File tree

‎apps/desktop/src/ipc/methods/tailcatEnvironment.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import * as DesktopTailcatEnvironment from "../../tailcat/DesktopTailcatEnvironm
1818
* diagnostics, and asks for lifecycle changes by connection id.
1919
*/
2020

21-
export const ensureTailcatEnvironment = DesktopIpc.makeIpcMethod({
21+
const ensureTailcatEnvironment = DesktopIpc.makeIpcMethod({
2222
channel: IpcChannels.ENSURE_TAILCAT_ENVIRONMENT_CHANNEL,
2323
payload: DesktopTailcatEnvironmentEnsureInputSchema,
2424
result: DesktopTailcatEnvironmentBootstrapSchema,
@@ -28,7 +28,7 @@ export const ensureTailcatEnvironment = DesktopIpc.makeIpcMethod({
2828
}),
2929
});
3030

31-
export const restartTailcatEnvironment = DesktopIpc.makeIpcMethod({
31+
const restartTailcatEnvironment = DesktopIpc.makeIpcMethod({
3232
channel: IpcChannels.RESTART_TAILCAT_ENVIRONMENT_CHANNEL,
3333
payload: DesktopTailcatConnectionIdInputSchema,
3434
result: DesktopTailcatEnvironmentBootstrapSchema,
@@ -40,7 +40,7 @@ export const restartTailcatEnvironment = DesktopIpc.makeIpcMethod({
4040
}),
4141
});
4242

43-
export const disconnectTailcatEnvironment = DesktopIpc.makeIpcMethod({
43+
const disconnectTailcatEnvironment = DesktopIpc.makeIpcMethod({
4444
channel: IpcChannels.DISCONNECT_TAILCAT_ENVIRONMENT_CHANNEL,
4545
payload: DesktopTailcatConnectionIdInputSchema,
4646
result: Schema.Void,
@@ -52,7 +52,7 @@ export const disconnectTailcatEnvironment = DesktopIpc.makeIpcMethod({
5252
}),
5353
});
5454

55-
export const getTailcatConnectionDiagnostics = DesktopIpc.makeIpcMethod({
55+
const getTailcatConnectionDiagnostics = DesktopIpc.makeIpcMethod({
5656
channel: IpcChannels.GET_TAILCAT_CONNECTION_DIAGNOSTICS_CHANNEL,
5757
payload: DesktopTailcatConnectionIdInputSchema,
5858
result: Schema.NullOr(TailcatConnectionDiagnostics),
@@ -62,7 +62,7 @@ export const getTailcatConnectionDiagnostics = DesktopIpc.makeIpcMethod({
6262
}),
6363
});
6464

65-
export const probeTailcatConnectionPath = DesktopIpc.makeIpcMethod({
65+
const probeTailcatConnectionPath = DesktopIpc.makeIpcMethod({
6666
channel: IpcChannels.PROBE_TAILCAT_CONNECTION_PATH_CHANNEL,
6767
payload: DesktopTailcatConnectionIdInputSchema,
6868
result: Schema.NullOr(TailcatConnectionDiagnostics),

‎apps/desktop/src/tailcat/DesktopTailcatEnvironment.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ import * as DesktopTailcatIdentity from "./DesktopTailcatIdentity.ts";
4545
* probe result is kept for diagnostics.
4646
*/
4747

48-
export const TAILCAT_FORWARD_READINESS_TIMEOUT = Duration.seconds(20);
49-
export const TAILCAT_FORWARD_MAX_RESTARTS = 8;
48+
const TAILCAT_FORWARD_READINESS_TIMEOUT = Duration.seconds(20);
49+
const TAILCAT_FORWARD_MAX_RESTARTS = 8;
5050

5151
export class DesktopTailcatEnvironmentError extends Schema.TaggedError<DesktopTailcatEnvironmentError>()(
5252
"DesktopTailcatEnvironmentError",
@@ -117,6 +117,7 @@ const failureCodeOf = (
117117
): TailcatFailureCode =>
118118
error._tag === "DesktopTailcatIdentityError" ? "identity-failed" : tailcatFailureCode(error);
119119

120+
/** @public Service construction is part of the canonical Effect module API. */
120121
export const make = Effect.gen(function* () {
121122
const runtime = yield* TailcatRuntime.TailcatRuntime;
122123
const identity = yield* DesktopTailcatIdentity.DesktopTailcatIdentity;

‎apps/desktop/src/tailcat/DesktopTailcatIdentity.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export class DesktopTailcatIdentity extends Context.Service<
7474

7575
const describe = (cause: unknown) => (cause instanceof Error ? cause.message : String(cause));
7676

77+
/** @public Service construction is part of the canonical Effect module API. */
7778
export const make = Effect.gen(function* () {
7879
const environment = yield* DesktopEnvironment.DesktopEnvironment;
7980
const fileSystem = yield* FileSystem.FileSystem;

‎apps/desktop/src/tailcat/DesktopTailcatRuntime.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
1414
* `native/tailcat/dist` output. A `tailcat` on PATH is the last resort and is
1515
* still version-checked against the pinned manifest.
1616
*/
17-
export function desktopTailcatBundledCandidates(
17+
function desktopTailcatBundledCandidates(
1818
environment: DesktopEnvironment.DesktopEnvironment["Service"],
1919
): ReadonlyArray<string> {
2020
const architecture = environment.processArch as NodeJS.Architecture;

‎apps/server/src/cli/peer.ts‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const uniqueScopesOrDefault = (
121121
): ReadonlyArray<FederationScope> =>
122122
scopes.length === 0 ? FEDERATION_DEFAULT_SCOPES : Array.from(new Set(scopes));
123123

124-
export const formatPeer = (peer: FederationPeer): string =>
124+
const formatPeer = (peer: FederationPeer): string =>
125125
[
126126
`${peer.label} (${peer.peerId}) ${peer.status}`,
127127
` fingerprint: ${peer.publicKeyFingerprint}`,
@@ -137,13 +137,10 @@ export const formatPeer = (peer: FederationPeer): string =>
137137
...(peer.lastError === null ? [] : [` last error: ${peer.lastError}`]),
138138
].join("\n");
139139

140-
export const formatPairedPeer = (
141-
peer: FederationPeer,
142-
options: { readonly json: boolean },
143-
): string =>
140+
const formatPairedPeer = (peer: FederationPeer, options: { readonly json: boolean }): string =>
144141
options.json ? JSON.stringify(peer, null, 2) : `Paired with a new peer.\n\n${formatPeer(peer)}`;
145142

146-
export const formatPeerList = (
143+
const formatPeerList = (
147144
snapshot: FederationSnapshot,
148145
options: { readonly json: boolean },
149146
): string => {
@@ -157,7 +154,7 @@ export const formatPeerList = (
157154
return [header, "", snapshot.peers.map(formatPeer).join("\n\n")].join("\n");
158155
};
159156

160-
export const formatPeerCode = (
157+
const formatPeerCode = (
161158
issued: FederationPeerCodeResult,
162159
options: { readonly json: boolean },
163160
): string => {
@@ -174,7 +171,7 @@ export const formatPeerCode = (
174171
].join("\n");
175172
};
176173

177-
export const formatRemoteProjects = (
174+
const formatRemoteProjects = (
178175
projects: ReadonlyArray<FederationProjectSummary>,
179176
options: { readonly json: boolean },
180177
): string => {
@@ -191,10 +188,10 @@ export const formatRemoteProjects = (
191188
.join("\n\n");
192189
};
193190

194-
export const formatRunEvent = (event: FederationRunEvent): string =>
191+
const formatRunEvent = (event: FederationRunEvent): string =>
195192
`[${event.at}] ${event.type}${event.summary.length > 0 ? `: ${event.summary}` : ""}`;
196193

197-
export const formatRemoteRun = (
194+
const formatRemoteRun = (
198195
remoteRun: FederationRemoteRun,
199196
options: { readonly json: boolean },
200197
): string => {

‎apps/server/src/cli/remote.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { type DiscoveredPairTarget, discoverPairTarget, makePairServerConfig } f
5050
* Bound for one unary call against the running server: generous for a busy
5151
* disk, short enough that a wedged server does not hang the terminal.
5252
*/
53-
export const RUNNING_SERVER_REQUEST_TIMEOUT = Duration.seconds(10);
53+
const RUNNING_SERVER_REQUEST_TIMEOUT = Duration.seconds(10);
5454

5555
// Enabling starts the tailcat process and waits for it to report an address;
5656
// a cold start with a DERP handshake is a few seconds, so poll for up to 30s.
@@ -280,7 +280,7 @@ const runTailcatCommand = <A, E, R>(
280280
run: (session) => Effect.flatMap(makeTailcatApi(session), run),
281281
}).pipe(Effect.provide(FetchHttpClient.layer));
282282

283-
export const nodeKeyFingerprint = tailcatNodeKeyFingerprint;
283+
const nodeKeyFingerprint = tailcatNodeKeyFingerprint;
284284

285285
const formatRuntime = (state: TailcatRemoteAccessState): string => {
286286
if (state.runtime === null) {
@@ -292,7 +292,7 @@ const formatRuntime = (state: TailcatRemoteAccessState): string => {
292292
return `${state.runtime.source} ${state.runtime.version} (${compatibility}) at ${state.runtime.executablePath}`;
293293
};
294294

295-
export const formatTailcatStatus = (
295+
const formatTailcatStatus = (
296296
state: TailcatRemoteAccessState,
297297
options: { readonly json: boolean },
298298
): string => {
@@ -317,7 +317,7 @@ export const formatTailcatStatus = (
317317
].join("\n");
318318
};
319319

320-
export const formatTrustedPeers = (
320+
const formatTrustedPeers = (
321321
peers: ReadonlyArray<TailcatTrustedPeer>,
322322
options: { readonly json: boolean },
323323
): string => {
@@ -351,7 +351,7 @@ export const formatTrustedPeers = (
351351

352352
// Same shape as the `t3 serve --tailcat` startup output, so the code reads
353353
// the same wherever the user sees it.
354-
export const formatConnectionCode = (
354+
const formatConnectionCode = (
355355
issued: TailcatConnectionCodeResult,
356356
options: { readonly json: boolean },
357357
): string => {

‎apps/server/src/federation/FederationIdentity.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
1616
* the secret store (also used for T3 Connect link proofs). Reusing it keeps one
1717
* stable cryptographic identity per environment instead of a second key system.
1818
*/
19-
export const FEDERATION_ASSERTION_MAX_AGE_SECONDS = 120;
19+
const FEDERATION_ASSERTION_MAX_AGE_SECONDS = 120;
2020

2121
export class FederationIdentity extends Context.Service<
2222
FederationIdentity,
@@ -72,6 +72,7 @@ export function federationKeyFingerprint(publicKeyPem: string): string {
7272
return `${hex.slice(0, 4)}·${hex.slice(4, 8)}·${hex.slice(8, 12)}·${hex.slice(12, 16)}`;
7373
}
7474

75+
/** @public Service construction is part of the canonical Effect module API. */
7576
export const make = Effect.gen(function* () {
7677
const secrets = yield* ServerSecretStore.ServerSecretStore;
7778
const environment = yield* ServerEnvironment.ServerEnvironment;

‎apps/server/src/federation/FederationService.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ import {
105105
* at pairing time; a transport path never implies trust by itself.
106106
*/
107107

108-
export const FEDERATION_CAPABILITIES: ReadonlyArray<FederationCapability> = [
108+
const FEDERATION_CAPABILITIES: ReadonlyArray<FederationCapability> = [
109109
"hello",
110110
"projects.list",
111111
"runs.start",
@@ -258,6 +258,7 @@ function scopesIncludeAll(
258258
return required.every((scope) => granted.includes(scope));
259259
}
260260

261+
/** @public Service construction is part of the canonical Effect module API. */
261262
export const make = Effect.gen(function* () {
262263
const config = yield* ServerConfig.ServerConfig;
263264
const identity = yield* FederationIdentity.FederationIdentity;

‎apps/server/src/federation/FederationTransport.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import * as ServerConfig from "../config.ts";
2929
* Tailcat client identity. Forwards are created lazily, reused while healthy,
3030
* and closed when the peer is removed or the server shuts down.
3131
*/
32-
export const TAILCAT_CLIENT_IDENTITY_FILE = "tailcat-client-identity.private.json";
32+
const TAILCAT_CLIENT_IDENTITY_FILE = "tailcat-client-identity.private.json";
3333
const PEER_READY_TIMEOUT = Duration.seconds(25);
3434

3535
export interface PeerEndpoint {

‎apps/server/src/tailcat/TailcatRemoteAccess.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ const isPermanentFailure = (code: TailcatFailureCode): boolean =>
192192
code === "version-incompatible" ||
193193
code === "identity-failed";
194194

195+
/** @public Service construction is part of the canonical Effect module API. */
195196
export const make = Effect.gen(function* () {
196197
const config = yield* ServerConfig.ServerConfig;
197198
const runtime = yield* TailcatRuntime.TailcatRuntime;

0 commit comments

Comments
 (0)