refactor: rename registerExecution to attachExecution for clarity

The "attach" verb makes it clear that the caller brings an existing
process/handle, while "create" (createExecution) means the lifecycle
service allocates and owns the execution from scratch.
This commit is contained in:
Adam Weidman
2026-03-09 00:43:41 -04:00
parent e17e34d18f
commit 013cfafbf9
4 changed files with 97 additions and 10 deletions
@@ -155,7 +155,7 @@ describe('ExecutionLifecycleService', () => {
const chunks: string[] = [];
let output = 'seed';
const handle: ExecutionHandle = ExecutionLifecycleService.registerExecution(
const handle: ExecutionHandle = ExecutionLifecycleService.attachExecution(
4321,
{
executionMethod: 'child_process',
@@ -211,7 +211,7 @@ describe('ExecutionLifecycleService', () => {
it('supports late subscription catch-up after backgrounding an external execution', async () => {
let output = 'seed';
const onExit = vi.fn();
const handle = ExecutionLifecycleService.registerExecution(4322, {
const handle = ExecutionLifecycleService.attachExecution(4322, {
executionMethod: 'child_process',
getBackgroundOutput: () => output,
getSubscriptionSnapshot: () => output,
@@ -258,7 +258,7 @@ describe('ExecutionLifecycleService', () => {
it('kills external executions and settles pending promises', async () => {
const terminate = vi.fn();
const onExit = vi.fn();
const handle = ExecutionLifecycleService.registerExecution(4323, {
const handle = ExecutionLifecycleService.attachExecution(4323, {
executionMethod: 'child_process',
initialOutput: 'running',
kill: terminate,
@@ -276,14 +276,14 @@ describe('ExecutionLifecycleService', () => {
});
it('rejects duplicate execution registration for active execution IDs', () => {
ExecutionLifecycleService.registerExecution(4324, {
ExecutionLifecycleService.attachExecution(4324, {
executionMethod: 'child_process',
});
expect(() => {
ExecutionLifecycleService.registerExecution(4324, {
ExecutionLifecycleService.attachExecution(4324, {
executionMethod: 'child_process',
});
}).toThrow('Execution 4324 is already registered.');
}).toThrow('Execution 4324 is already attached.');
});
});
@@ -167,12 +167,12 @@ export class ExecutionLifecycleService {
this.nextExecutionId = NON_PROCESS_EXECUTION_ID_START;
}
static registerExecution(
static attachExecution(
executionId: number,
registration: ExternalExecutionRegistration,
): ExecutionHandle {
if (this.activeExecutions.has(executionId) || this.activeResolvers.has(executionId)) {
throw new Error(`Execution ${executionId} is already registered.`);
throw new Error(`Execution ${executionId} is already attached.`);
}
this.exitedExecutionInfo.delete(executionId);
@@ -258,7 +258,7 @@ export class ShellExecutionService {
};
const lifecycleHandle = child.pid
? ExecutionLifecycleService.registerExecution(child.pid, {
? ExecutionLifecycleService.attachExecution(child.pid, {
executionMethod: 'child_process',
getBackgroundOutput: () => state.output,
getSubscriptionSnapshot: () => state.output || undefined,
@@ -554,7 +554,7 @@ export class ShellExecutionService {
maxSerializedLines: shellExecutionConfig.maxSerializedLines,
});
const result = ExecutionLifecycleService.registerExecution(ptyPid, {
const result = ExecutionLifecycleService.attachExecution(ptyPid, {
executionMethod: ptyInfo?.name ?? 'node-pty',
writeInput: (input) => {
if (!ExecutionLifecycleService.isActive(ptyPid)) {