Skip to content

Commit f1458a9

Browse files
mchwangclaude
andcommitted
Pass D's runnerOwner through the runner coordinator
Lane D (#71) made runnerOwner a required InvocationInput field and refuses task storage owned by another runner. The injected D now supplies the token in RunnerDeps, so preparation and the start call use the same one. F1d replaces the source with the per-database runner token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8b2632a commit f1458a9

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎runner/coordinator.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ export interface PreparedAttempt {
1010
readonly approvedArgv: readonly (readonly string[])[];
1111
}
1212
export interface RunnerDeps {
13+
/**
14+
* The runner token D labels every resource with (32 lowercase hex characters). `prepare` must allocate task storage
15+
* under the same token, because D refuses storage owned by another runner.
16+
*/
17+
readonly runnerOwner: string;
1318
/**
1419
* Host-side preparation (clone, prompt). On abort it must stop and await every subprocess it started, then reject.
1520
* It never leaves work running after it settles.
@@ -172,7 +177,7 @@ export class RunnerCoordinator {
172177
let handle: InvocationHandle;
173178
try {
174179
const input = captureInvocation({ clone: prepared.clone, phase: ATTEMPT_PHASES[attempt.kind], vendor: prepared.vendor,
175-
approvedArgv: prepared.approvedArgv, deadline: attempt.deadline, attemptId: attempt.id, context: attempt.context }, now);
180+
approvedArgv: prepared.approvedArgv, deadline: attempt.deadline, attemptId: attempt.id, runnerOwner: this.#deps.runnerOwner, context: attempt.context }, now);
176181
handle = this.#deps.start(input, prepared);
177182
} catch (error) { return await this.#endBeforeLaunch(job, attempt, { detail: `Launch failed: ${message(error)}` }); }
178183
job.handle = handle;

‎test/runner-coordinator.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { PlanIdentity } from '../core/identity.ts';
1010
import type { Plan, PlanContext } from '../core/plan.ts';
1111

1212
const oid = (n: number) => n.toString(16).padStart(40, '0');
13+
const RUNNER_OWNER = '0123456789abcdef0123456789abcdef';
1314
const plan = (summary = 'Example'): Plan => ({ schema_version: 1, revision: 1, issue: 1, summary, questions: [], items: [{ id: 'P1', title: 'Change', intent: 'Improve', files: [{ path: 'a', kind: 'edit', renamed_from: null, change: 'Change' }], acceptance: [{ type: 'check', text: 'Works' }], depends_on: [] }] });
1415
const ctx = (identity: PlanIdentity): PlanContext => ({ identity, issue: 1, baseEntries: [{ path: 'a', kind: 'file' }], pathKey: p => p, allowedCommands: [] });
1516
const A = { repositoryId: 'repo', taskId: 'task-a', planId: 'plan' }, B = { repositoryId: 'repo', taskId: 'task-b', planId: 'plan' };
@@ -29,6 +30,7 @@ function fakeD(options: { prepareIgnoresAbort?: boolean } = {}) {
2930
let cleaned = 0, startError: Error | undefined;
3031
const prepared = (attemptId: string): PreparedAttempt => ({ clone: { id: `clone-${attemptId}`, taskId: 'task', directory: '/tmp/x', head: oid(2) }, vendor: 'claude', approvedArgv: [] });
3132
const deps: RunnerDeps = {
33+
runnerOwner: RUNNER_OWNER,
3234
prepare: (attempt, signal) => new Promise((resolve, reject) => {
3335
preparations.push({ attemptId: attempt.id, signal, resolve: () => resolve(prepared(attempt.id)), reject });
3436
if (!options.prepareIgnoresAbort) signal.addEventListener('abort', () => reject(signal.reason), { once: true });
@@ -74,6 +76,7 @@ describe('admission and slots', () => {
7476
const attempt = runner.start(A, request(store, A));
7577
await until(() => preparations.length === 1, 'preparation'); preparations[0]!.resolve();
7678
await until(() => launches.length === 1, 'launch');
79+
expect(launches[0]!.input.runnerOwner).toBe(RUNNER_OWNER);
7780
expect(store.getAttempt(A, attempt.id).state).toBe('running');
7881
launches[0]!.settle();
7982
await runner.settled(A);

0 commit comments

Comments
 (0)