chore: resolve lint warnings across v2 code

Hoist inline Schema compiles to module scope, drop unused
imports/vars, stabilize react-markdown component identities via a
module-scope factory, remove useless spreads, and use data-derived
keys for release-note bullets. No behavior changes.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Fable 5 committed 2026-08-14 11:23:32 +02:00
1 parent 94b7d5f7e1
commit bb23ddfa90
17 files changed
+449 -377

No files matched your search

@@ -31,6 +31,27 @@ const StubServicesLive = Layer.mergeAll(
Layer.mock(VcsStatusBroadcaster)({}),
);
const ToolsListPayload = Schema.fromJsonString(
Schema.Struct({
result: Schema.Struct({
tools: Schema.Array(
Schema.Struct({
name: Schema.String,
inputSchema: Schema.Struct({ type: Schema.optional(Schema.String) }),
annotations: Schema.optional(
Schema.Struct({
readOnlyHint: Schema.optional(Schema.Boolean),
destructiveHint: Schema.optional(Schema.Boolean),
openWorldHint: Schema.optional(Schema.Boolean),
}),
),
}),
),
}),
}),
);
const decodeToolsListPayload = Schema.decodeUnknownEffect(ToolsListPayload);
it.effect("production mcp layer lists worktree tools over http", () =>
Effect.scoped(
Effect.gen(function* () {
@@ -84,28 +105,7 @@ it.effect("production mcp layer lists worktree tools over http", () =>
),
});
const bodyText = yield* listResponse.text;
const ToolsListPayload = Schema.fromJsonString(
Schema.Struct({
result: Schema.Struct({
tools: Schema.Array(
Schema.Struct({
name: Schema.String,
inputSchema: Schema.Struct({ type: Schema.optional(Schema.String) }),
annotations: Schema.optional(
Schema.Struct({
readOnlyHint: Schema.optional(Schema.Boolean),
destructiveHint: Schema.optional(Schema.Boolean),
openWorldHint: Schema.optional(Schema.Boolean),
}),
),
}),
),
}),
}),
);
const payload = yield* Schema.decodeUnknownEffect(ToolsListPayload)(
bodyText.match(/\{.*\}/s)![0],
);
const payload = yield* decodeToolsListPayload(bodyText.match(/\{.*\}/s)![0]);
const tools = payload.result.tools;
const toolNames = tools.map((tool) => tool.name);
expect(toolNames).toContain("t3_worktree_handoff");
@@ -2994,8 +2994,12 @@ describe("ClaudeAdapterV2 query message stream", () => {
let closed = false;
let releaseRead = () => {};
const readStarted = Promise.withResolvers<void>();
// Never yields a message — the read stays pending until close() flips
// `closed` and releases the in-flight await.
// oxlint-disable-next-line require-yield
async function* sdkMessages(): AsyncGenerator<SDKMessage, void> {
while (!closed) {
for (;;) {
if (closed) return;
await new Promise<void>((resolve) => {
releaseRead = resolve;
readStarted.resolve();
@@ -660,14 +660,17 @@ function nativeSessionIdFor(transcript: ClaudeAgentSdkReplayTranscript): string
: "00000000-0000-4000-8000-000000000000";
}
const isClaudeAgentSdkQueryRunnerError = Schema.is(ClaudeAgentSdkQueryRunnerError);
const isClaudeAgentSdkReplayError = Schema.is(ClaudeAgentSdkReplayError);
function replayQueryRunnerError(
transcript: ClaudeAgentSdkReplayTranscript,
cause: unknown,
): ClaudeAgentSdkQueryRunnerError {
if (Schema.is(ClaudeAgentSdkQueryRunnerError)(cause)) {
if (isClaudeAgentSdkQueryRunnerError(cause)) {
return cause;
}
const replayCause = Schema.is(ClaudeAgentSdkReplayError)(cause)
const replayCause = isClaudeAgentSdkReplayError(cause)
? cause
: new ClaudeReplayDriverError({ scenario: transcript.scenario, cause });
return new ClaudeAgentSdkQueryRunnerError({
@@ -2410,13 +2413,17 @@ export async function recordClaudeAgentSdkReplayTranscript(input: {
};
}
const decodeClaudeAgentSdkReplayTranscript = Schema.decodeUnknownEffect(
ClaudeAgentSdkReplayTranscript,
);
export const ClaudeOrchestratorReplayHarness: OrchestratorV2ProviderReplayHarness<
ClaudeAgentSdkReplayTranscript,
ClaudeOrchestratorReplayHarnessError
> = {
driver: CLAUDE_PROVIDER,
decodeTranscript: (transcript) =>
Schema.decodeUnknownEffect(ClaudeAgentSdkReplayTranscript)(transcript).pipe(
decodeClaudeAgentSdkReplayTranscript(transcript).pipe(
Effect.mapError(
(cause) =>
new ClaudeReplayTranscriptDecodeError({
@@ -308,8 +308,14 @@ export interface ClaudeAgentSdkSessionForkInput {
readonly providerSessionId: OrchestrationV2ProviderSession["id"];
}
const isClaudeAgentSdkQueryRunnerError = Schema.is(ClaudeAgentSdkQueryRunnerError);
const isProviderAdapterRuntimeRequestResponseError = Schema.is(
ProviderAdapterRuntimeRequestResponseError,
);
const isProviderAdapterRollbackThreadError = Schema.is(ProviderAdapterRollbackThreadError);
function queryRunnerError(cause: unknown, method: string): ClaudeAgentSdkQueryRunnerError {
return Schema.is(ClaudeAgentSdkQueryRunnerError)(cause)
return isClaudeAgentSdkQueryRunnerError(cause)
? cause
: new ClaudeAgentSdkQueryRunnerError({ cause, method });
}
@@ -1105,6 +1111,7 @@ const ClaudeRuntimeSandboxPolicyKind = Schema.Struct({
});
type ClaudeRuntimeSandboxPolicy = typeof ClaudeRuntimeSandboxPolicyKind.Type;
type ClaudeRuntimeSandboxPolicyKindName = ClaudeRuntimeSandboxPolicy["type"];
const isClaudeRuntimeSandboxPolicyKind = Schema.is(ClaudeRuntimeSandboxPolicyKind);
const ClaudeRuntimeReadOnlyFullAccessSandboxPolicy = Schema.Struct({
type: Schema.Literal("readOnly"),
@@ -1112,12 +1119,15 @@ const ClaudeRuntimeReadOnlyFullAccessSandboxPolicy = Schema.Struct({
type: Schema.Literal("fullAccess"),
}),
});
const isClaudeRuntimeReadOnlyFullAccessSandboxPolicy = Schema.is(
ClaudeRuntimeReadOnlyFullAccessSandboxPolicy,
);
function sandboxPolicyKindForClaudeRuntimePolicy(
runtimePolicy: ProviderAdapterV2RuntimePolicy,
): ClaudeRuntimeSandboxPolicyKindName | undefined {
return runtimePolicy.sandboxPolicy !== undefined &&
Schema.is(ClaudeRuntimeSandboxPolicyKind)(runtimePolicy.sandboxPolicy)
isClaudeRuntimeSandboxPolicyKind(runtimePolicy.sandboxPolicy)
? runtimePolicy.sandboxPolicy.type
: undefined;
}
@@ -1125,7 +1135,7 @@ function sandboxPolicyKindForClaudeRuntimePolicy(
function readOnlyPolicyAllowsGlobalReads(runtimePolicy: ProviderAdapterV2RuntimePolicy): boolean {
return (
runtimePolicy.sandboxPolicy !== undefined &&
Schema.is(ClaudeRuntimeReadOnlyFullAccessSandboxPolicy)(runtimePolicy.sandboxPolicy)
isClaudeRuntimeReadOnlyFullAccessSandboxPolicy(runtimePolicy.sandboxPolicy)
);
}
@@ -1329,6 +1339,7 @@ function isClaudeWebSearchOutput(output: unknown): output is WebSearchOutput {
const ClaudeNativeToolInputRecord = Schema.Record(Schema.String, Schema.Unknown);
type ClaudeNativeToolInputRecord = typeof ClaudeNativeToolInputRecord.Type;
const isClaudeNativeToolInputRecord = Schema.is(ClaudeNativeToolInputRecord);
type ClaudeNativeToolInput =
| {
@@ -1346,7 +1357,7 @@ const EMPTY_CLAUDE_NATIVE_TOOL_INPUT = {
} satisfies ClaudeNativeToolInput;
function claudeNativeToolInputFromUnknown(input: unknown): ClaudeNativeToolInput {
return Schema.is(ClaudeNativeToolInputRecord)(input)
return isClaudeNativeToolInputRecord(input)
? { type: "record", value: input }
: { type: "non_record", value: input };
}
@@ -4054,7 +4065,7 @@ export function makeClaudeAdapterV2(
(effect, requestInput) =>
effect.pipe(
Effect.mapError((cause) =>
Schema.is(ProviderAdapterRuntimeRequestResponseError)(cause)
isProviderAdapterRuntimeRequestResponseError(cause)
? cause
: new ProviderAdapterRuntimeRequestResponseError({
driver: CLAUDE_PROVIDER,
@@ -4137,7 +4148,7 @@ export function makeClaudeAdapterV2(
(effect, rollbackInput) =>
effect.pipe(
Effect.mapError((cause) =>
Schema.is(ProviderAdapterRollbackThreadError)(cause)
isProviderAdapterRollbackThreadError(cause)
? cause
: new ProviderAdapterRollbackThreadError({
driver: CLAUDE_PROVIDER,
@@ -186,13 +186,17 @@ export function makeCodexProviderAdapterRegistryReplayLayer(input: {
return registryLayer;
}
const decodeCodexAppServerReplayTranscript = Schema.decodeUnknownEffect(
CodexReplay.CodexAppServerReplayTranscript,
);
export const CodexOrchestratorReplayHarness: OrchestratorV2ProviderReplayHarness<
CodexReplay.CodexAppServerReplayTranscript,
CodexOrchestratorReplayHarnessError
> = {
driver: CODEX_DRIVER_KIND,
decodeTranscript: (transcript) =>
Schema.decodeUnknownEffect(CodexReplay.CodexAppServerReplayTranscript)(transcript).pipe(
decodeCodexAppServerReplayTranscript(transcript).pipe(
Effect.mapError(
(cause) =>
new CodexReplayTranscriptDecodeError({
@@ -30,6 +30,8 @@ export class CheckpointCaptureExecutionError extends Schema.TaggedErrorClass<Che
},
) {}
const isCheckpointCaptureExecutionError = Schema.is(CheckpointCaptureExecutionError);
export interface CheckpointCaptureServiceV2Shape {
readonly execute: (input: {
readonly threadId: ThreadId;
@@ -223,7 +225,7 @@ export const layer: Layer.Layer<
execute: (input) =>
execute(input).pipe(
Effect.mapError((cause) =>
Schema.is(CheckpointCaptureExecutionError)(cause)
isCheckpointCaptureExecutionError(cause)
? cause
: new CheckpointCaptureExecutionError({ ...input, cause }),
),
@@ -473,40 +473,56 @@ const encodeContextTransferPayload = Schema.encodeEffect(
Schema.fromJsonString(OrchestrationV2ContextTransferJsonSchema),
);
const decodeThreadPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2AppThreadJsonSchema))(json);
const decodeRunPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2RunJsonSchema))(json);
const decodeRunAttemptPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2RunAttemptJsonSchema))(json);
const decodeNodePayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2ExecutionNodeJsonSchema))(json);
const decodeSubagentPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2SubagentJsonSchema))(json);
const decodeProviderSessionPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2ProviderSessionJsonSchema))(json);
const decodeProviderThreadPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2ProviderThreadJsonSchema))(json);
const decodeProviderTurnPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2ProviderTurnJsonSchema))(json);
const decodeRuntimeRequestPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2RuntimeRequestJsonSchema))(json);
const decodeMessagePayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2ConversationMessageJsonSchema))(
json,
);
const decodePlanPayload = (json: string) =>
Schema.decodeUnknownEffect(OrchestrationV2PlanArtifactSchema)(parseEncodedPayload(json));
const decodeTurnItemPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2TurnItemJsonSchema))(json);
const decodeCheckpointScopePayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2CheckpointScopeJsonSchema))(json);
const decodeCheckpointPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2CheckpointJsonSchema))(json);
const decodeContextHandoffPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2ContextHandoffJsonSchema))(json);
const decodeContextTransferPayload = (json: string) =>
Schema.decodeUnknownEffect(Schema.fromJsonString(OrchestrationV2ContextTransferJsonSchema))(json);
const decodeThreadPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2AppThreadJsonSchema),
);
const decodeRunPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2RunJsonSchema),
);
const decodeRunAttemptPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2RunAttemptJsonSchema),
);
const decodeNodePayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2ExecutionNodeJsonSchema),
);
const decodeSubagentPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2SubagentJsonSchema),
);
const decodeProviderSessionPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2ProviderSessionJsonSchema),
);
const decodeProviderThreadPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2ProviderThreadJsonSchema),
);
const decodeProviderTurnPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2ProviderTurnJsonSchema),
);
const decodeRuntimeRequestPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2RuntimeRequestJsonSchema),
);
const decodeMessagePayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2ConversationMessageJsonSchema),
);
const decodePlanArtifact = Schema.decodeUnknownEffect(OrchestrationV2PlanArtifactSchema);
const decodePlanPayload = (json: string) => decodePlanArtifact(parseEncodedPayload(json));
const decodeTurnItemPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2TurnItemJsonSchema),
);
const decodeCheckpointScopePayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2CheckpointScopeJsonSchema),
);
const decodeCheckpointPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2CheckpointJsonSchema),
);
const decodeContextHandoffPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2ContextHandoffJsonSchema),
);
const decodeContextTransferPayload = Schema.decodeUnknownEffect(
Schema.fromJsonString(OrchestrationV2ContextTransferJsonSchema),
);
const isProjectionStoreThreadNotFoundError = Schema.is(ProjectionStoreThreadNotFoundError);
const isProjectionStoreReadError = Schema.is(ProjectionStoreReadError);
function parseEncodedPayload(json: string): Record<string, unknown> {
return JSON.parse(json) as Record<string, unknown>;
@@ -2044,7 +2060,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
return withLocalVisibleTurnItems(projection);
}).pipe(
Effect.mapError((cause) =>
Schema.is(ProjectionStoreThreadNotFoundError)(cause)
isProjectionStoreThreadNotFoundError(cause)
? cause
: new ProjectionStoreReadError({
threadId,
@@ -2101,8 +2117,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
)
.pipe(
Effect.mapError((cause) =>
Schema.is(ProjectionStoreThreadNotFoundError)(cause) ||
Schema.is(ProjectionStoreReadError)(cause)
isProjectionStoreThreadNotFoundError(cause) || isProjectionStoreReadError(cause)
? cause
: new ProjectionStoreReadError({ threadId, cause }),
),
@@ -14,6 +14,8 @@ export class TurnItemPositionStoreError extends Schema.TaggedErrorClass<TurnItem
},
) {}
const isTurnItemPositionStoreError = Schema.is(TurnItemPositionStoreError);
export interface TurnItemPositionStoreV2Shape {
readonly allocate: (input: {
readonly threadId: ThreadId;
@@ -85,7 +87,7 @@ export const layer: Layer.Layer<TurnItemPositionStoreV2, never, SqlClient.SqlCli
return ordinal;
}).pipe(
Effect.mapError((cause) =>
Schema.is(TurnItemPositionStoreError)(cause)
isTurnItemPositionStoreError(cause)
? cause
: new TurnItemPositionStoreError({ threadId, turnItemId, cause }),
),
@@ -116,7 +116,7 @@ describe("terminatePosixOwnedProcessTree", () => {
});
it.live("sweeps empty t3-acp sibling leases owned by dead pids only", () =>
Effect.gen(function* () {
Effect.sync(() => {
const scratchRoot = NodePath.join(process.cwd(), "tmp");
NodeFS.mkdirSync(scratchRoot, { recursive: true });
const parent = NodeFS.mkdtempSync(NodePath.join(scratchRoot, "acp-cgroup-stale-siblings-"));
@@ -670,7 +670,7 @@ export function observePosixOwnershipLedger(input: {
if (reservedPid !== undefined && !samePosixProcessIdentity(reservedPid, child)) {
// PID reused under an owned parent; drop the stale reservation.
input.frontier.delete(child.pid);
for (const [key, owned] of [...input.ledger.entries()]) {
for (const [key, owned] of input.ledger.entries()) {
if (owned.pid === child.pid) input.ledger.delete(key);
}
reservedPid = undefined;
@@ -802,7 +802,7 @@ export function capturePosixOwnershipLedger(input: {
// matches the live process at that PID. Either case can block admission of a
// legitimate child after PID reuse. Keep the root reservation even if the
// root briefly disappears mid-teardown (finalizer retry still needs it).
for (const [key, owned] of [...input.ledger.entries()]) {
for (const [key, owned] of input.ledger.entries()) {
if (owned.pid === input.rootPid) continue;
const live = byPid.get(owned.pid);
if (live === undefined || !samePosixProcessIdentity(owned, live)) {
-7
View File
@@ -335,13 +335,6 @@ const ServerWsRpcGroup = WsRpcGroup;
// Matches the event store's default page size (DEFAULT_READ_FROM_SEQUENCE_LIMIT).
const SHELL_RESUME_MAX_GAP = 1_000;
// Same bound for thread resume. The replay reads the *global* event range and
// filters per-thread afterwards, so a stale cursor far behind the head would
// otherwise decode every intervening event's payload — reconnects with cursors
// hundreds of thousands of events behind have OOM-killed servers on large
// databases. Past this gap the client is reset with a fresh thread snapshot.
const THREAD_RESUME_MAX_GAP = 1_000;
function toAuthAccessStreamEvent(
change: PairingGrantStore.BootstrapCredentialChange | SessionStore.SessionCredentialChange,
revision: number,