Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/server/src/processRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,11 @@ describe("isWindowsCommandNotFound", () => {
}),
);
});

describe("commandName", () => {
it("drops the directory from POSIX and Windows paths", () => {
expect(ProcessRunner.commandName("/Users/me/.local/bin/claude")).toBe("claude");
expect(ProcessRunner.commandName("C:\\Program Files\\nodejs\\npx.cmd")).toBe("npx.cmd");
expect(ProcessRunner.commandName("git")).toBe("git");
});
});
4 changes: 4 additions & 0 deletions apps/server/src/processRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,14 @@ function finalizeRunProcess<R>(
);
}

/** The executable name without its directory, recorded as `process.command` on process spans. */
export const commandName = (command: string) => command.replace(/^.*[\\/]/, "");

const runProcessCore = Effect.fn("processRunner.runProcessCore")(function* (
spawner: ChildProcessSpawner.ChildProcessSpawner["Service"],
input: ProcessRunInput,
): Effect.fn.Return<ProcessRunOutput, ProcessRunError, Scope.Scope> {
yield* Effect.annotateCurrentSpan("process.command", commandName(input.command));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.command can contain an arbitrary caller-supplied basename (including a renamed process.execPath), so stripping directories does not make this span annotation safe or bounded. Consider mapping only known executable names to fixed values and using a fixed fallback for unknown names; add a focused test for a custom basename.

Posted via Macroscope — Effect Service Conventions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this. Spans in this repo already carry full paths (git.cwd at apps/server/src/vcs/GitVcsDriverCore.ts:979, terminal.cwd at apps/server/src/terminal/Manager.ts:2211), and ProcessRunError already records the full command path (apps/server/src/processRunner.ts:52). A basename is not a command argument, and the set of real values is the small set of binaries T3 spawns, so a fixed fallback would only hide what the span is for.

const maxOutputBytes = input.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;
const outputMode = input.outputMode ?? "error";
const truncatedMarker = input.truncatedMarker ?? "";
Expand Down
Loading