GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): read workflow scripts from configured Claude homes by juliusmarminge · Pull Request #21970 · pingdotgg/t3code

fix(server): read workflow scripts from configured Claude homes #21970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
juliusmarminge wants to merge 12 commits into main from scheduler-tasks-05/claude-homes
+331 −39
Open

fix(server): read workflow scripts from configured Claude homes #21970

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
12 commits
Select commit Hold shift + click to select a range
b328c40
test(server): cover Claude configured-home reads and native forks
juliusmarminge Oct 19, 2026
cfb767f
test(server): use typed configured Claude instance fixtures
juliusmarminge Oct 19, 2026
911b3f1
fix(server): honor configured Claude homes for workflow scripts
juliusmarminge Oct 19, 2026
d58056a
test(server): isolate malformed Claude workflow configuration
juliusmarminge Oct 19, 2026
b308f46
fix(server): skip malformed Claude workflow configurations
juliusmarminge Oct 19, 2026
ad6a3f8
test(server): reproduce relative Claude workflow home failure
juliusmarminge Oct 19, 2026
0627cb7
fix(server): resolve relative Claude workflow roots from the thread
juliusmarminge Oct 19, 2026
d2c358a
test(server): compose workflow fixture layers together
juliusmarminge Oct 19, 2026
2c89316
Merge origin/main into scheduler-tasks-05/claude-homes
juliusmarminge Nov 14, 2026
c0ac811
test(server): cover Claude workflow homes with one thread fixture
juliusmarminge Nov 14, 2026
f152faf
refactor(server): serve workflow scripts from a WorkflowScriptQuery s…
juliusmarminge Nov 14, 2026
6989893
fix(server): read workflow scripts from a secret-backed CLAUDE_CONFIG…
juliusmarminge Nov 14, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

180 changes: 162 additions & 18 deletions 180 apps/server/src/orchestration-v2/workflowScriptQuery.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,36 @@ import * as NodeFS from "node:fs";
import * as NodeOS from "node:os";
import * as NodePath from "node:path";
import * as NodeChildProcess from "node:child_process";
import {
CommandId,
ProjectId,
ThreadId,
ProviderInstanceId,
ProviderDriverKind,
SecretProviderId,
} from "@t3tools/contracts";
import * as SecretResolver from "@t3tools/secret-provider-core/server/SecretResolver";
import * as HostProcess from "@t3tools/shared/HostProcess";
import { it as effectIt } from "@effect/vitest";
import * as Effect from "effect/Effect";
import { afterAll, assert, describe } from "vite-plus/test";
import { afterAll, assert } from "vite-plus/test";
import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
import { readWorkflowScript } from "./workflowScriptQuery.ts";
import * as WorkflowScriptQuery from "./workflowScriptQuery.ts";
import * as Settings from "../serverSettings.ts";
import * as Orchestrator from "./Orchestrator.ts";
import * as ProjectStore from "./ProjectStore.ts";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
import * as Layer from "effect/Layer";
import * as NodePathService from "@effect/platform-node/NodePath";

const root = NodePath.join(NodeOS.homedir(), ".claude", "projects", "__wf_script_test__");
const sandbox = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "wf-script-"));
const home = NodePath.join(sandbox, "home");
const root = NodePath.join(home, ".claude", "projects", "test");
NodeFS.mkdirSync(root, { recursive: true });
const scriptPath = NodePath.join(root, "run.js");
NodeFS.writeFileSync(scriptPath, "export const meta = {};\n");
const outside = NodePath.join(NodeOS.tmpdir(), "wf-outside.js");
const outside = NodePath.join(sandbox, "outside.js");
NodeFS.writeFileSync(outside, "evil\n");
const link = NodePath.join(root, "sneaky.js");
if (symlinksSupported) {
Expand All @@ -26,38 +44,164 @@ if (symlinksSupported) {
}

afterAll(() => {
NodeFS.rmSync(root, { recursive: true, force: true });
NodeFS.rmSync(outside, { force: true });
NodeFS.rmSync(sandbox, { recursive: true, force: true });
});

describe("workflow script containment", () => {
const customHome = NodePath.join(sandbox, "custom");
const envHome = NodePath.join(sandbox, "environment");
const secretHome = NodePath.join(sandbox, "secret");
const checkout = NodePath.join(sandbox, "checkout");
const customScript = NodePath.join(customHome, "projects", "test", "run.js");
const envScript = NodePath.join(envHome, "projects", "test", "run.js");
const secretScript = NodePath.join(secretHome, "projects", "test", "run.js");
const relativeScript = NodePath.join(checkout, "claude-config", "projects", "test", "run.js");
for (const [file, contents] of [
[customScript, "custom home"],
[envScript, "environment home"],
[secretScript, "secret home"],
[relativeScript, "thread checkout home"],
] as const) {
NodeFS.mkdirSync(NodePath.dirname(file), { recursive: true });
NodeFS.writeFileSync(file, contents);
}

const threadId = ThreadId.make("workflow-script-fixture");
const orphanThreadId = ThreadId.make("workflow-script-orphan");
const fixture = Layer.effectDiscard(
Effect.gen(function* () {
const orchestrator = yield* Orchestrator.OrchestratorV2;
yield* orchestrator.dispatch({
type: "thread.create",
commandId: CommandId.make("workflow-script-fixture:create"),
threadId,
projectId: ProjectId.make("workflow-project"),
title: "Workflow",
modelSelection: { instanceId: ProviderInstanceId.make("claudeAgent"), model: "default" },
runtimeMode: "full-access",
interactionMode: "default",
branch: null,
worktreePath: checkout,
createdBy: "user",
creationSource: "web",
});
yield* orchestrator.dispatch({
type: "thread.create",
commandId: CommandId.make("workflow-script-orphan:create"),
threadId: orphanThreadId,
projectId: ProjectId.make("workflow-missing-project"),
title: "Orphan",
modelSelection: { instanceId: ProviderInstanceId.make("claudeAgent"), model: "default" },
runtimeMode: "full-access",
interactionMode: "default",
branch: null,
worktreePath: null,
createdBy: "user",
creationSource: "web",
});
}),
).pipe(
Layer.provideMerge(
ProviderReplayHarness.layerWithRegistry(
{ name: "workflow-script-fixture" },
ProviderAdapterRegistry.layerFromAdapters([]),
{ runEffectWorker: false },
),
),
);

const claude = ProviderDriverKind.make("claudeAgent");
const providerInstances = {
[ProviderInstanceId.make("claude-missing")]: {
driver: claude,
config: { homePath: NodePath.join(sandbox, "missing") },
},
// Explicit homes resolve against the server cwd and win over CLAUDE_CONFIG_DIR.
[ProviderInstanceId.make("claude-custom")]: {
driver: claude,
config: { homePath: NodePath.relative(process.cwd(), customHome) },
environment: [{ name: "CLAUDE_CONFIG_DIR", value: "ignored-config", sensitive: false }],
},
[ProviderInstanceId.make("claude-env")]: {
driver: claude,
environment: [{ name: "CLAUDE_CONFIG_DIR", value: envHome, sensitive: false }],
},
[ProviderInstanceId.make("claude-secret")]: {
driver: claude,
environment: [
{
name: "CLAUDE_CONFIG_DIR",
value: { provider: SecretProviderId.make("vault"), reference: "claude-home" },
sensitive: true,
},
],
},
// Inherited relative config dirs resolve against the thread checkout, as Claude Code does.
[ProviderInstanceId.make("claude-relative")]: {
driver: claude,
environment: [{ name: "CLAUDE_CONFIG_DIR", value: "claude-config", sensitive: false }],
},
[ProviderInstanceId.make("claude-malformed")]: {
driver: claude,
enabled: false,
config: { autoCompactWindow: "not-a-number" },
},
};

const read = (scriptPath: string) =>
WorkflowScriptQuery.WorkflowScriptQuery.use((query) =>
query.readWorkflowScript({ threadId, scriptPath }),
);

effectIt.layer(
WorkflowScriptQuery.layer.pipe(
Layer.provideMerge(Settings.layerTest({ providerInstances })),
Layer.provideMerge(
Layer.mock(SecretResolver.SecretResolver)({
read: (references) => Effect.succeed(references.map(() => secretHome)),
}),
),
Layer.provideMerge(Layer.succeed(HostProcess.HomeDirectory, home)),
Comment thread
juliusmarminge marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Layer.provideMerge(Layer.succeed(HostProcess.Environment, {})),
Layer.provideMerge(NodePathService.layer),
Layer.provideMerge(fixture),
Layer.provideMerge(Layer.mock(ProjectStore.ProjectStoreV2)({ get: () => Effect.succeedNone })),
),
)("workflow script containment", (effectIt) => {
effectIt.effect("reads scripts from every configured Claude home", () =>
Effect.gen(function* () {
assert.equal((yield* read(customScript)).contents, "custom home");
assert.equal((yield* read(envScript)).contents, "environment home");
assert.equal((yield* read(secretScript)).contents, "secret home");
assert.equal((yield* read(relativeScript)).contents, "thread checkout home");
const result = yield* read(scriptPath);
assert.include(result.contents, "export const meta");
assert.equal(result.truncated, false);
const orphan = yield* WorkflowScriptQuery.WorkflowScriptQuery.use((query) =>
query.readWorkflowScript({ threadId: orphanThreadId, scriptPath }),
).pipe(Effect.flip);
assert.equal(orphan.reason, "root-unavailable");
}),
);

effectIt.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
"rejects a FIFO without waiting for a writer",
() =>
Effect.gen(function* () {
const fifo = NodePath.join(root, "pipe.js");
NodeChildProcess.execFileSync("mkfifo", [fifo]);
const error = yield* Effect.flip(readWorkflowScript({ scriptPath: fifo }));
const error = yield* Effect.flip(read(fifo));
assert.equal(error.reason, "not-regular-file");
}),
);

effectIt.effect("serves a real script under the projects root", () =>
Effect.gen(function* () {
const result = yield* readWorkflowScript({ scriptPath });
assert.include(result.contents, "export const meta");
assert.equal(result.truncated, false);
}),
);

effectIt.effect.skipIf(!symlinksSupported)(
"rejects paths outside the root and symlink escapes",
() =>
Effect.gen(function* () {
const escaped = yield* Effect.exit(readWorkflowScript({ scriptPath: outside }));
const escaped = yield* Effect.exit(read(outside));
assert.equal(escaped._tag, "Failure");
const sneaky = yield* Effect.exit(
readWorkflowScript({ scriptPath: link }).pipe(
read(link).pipe(
Effect.flip,
Effect.map((error) => error.reason),
),
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.