@@ -10,6 +10,7 @@ import type { InvocationResult } from '../agents/contract.ts';
1010import type { Plan , PlanContext } from '../core/plan.ts' ;
1111
1212const oid = ( n : number ) => n . toString ( 16 ) . padStart ( 40 , '0' ) ;
13+ const RUNNER_OWNER = '0123456789abcdef0123456789abcdef' ;
1314const identity = { repositoryId : 'repo' , taskId : 'task' , planId : 'plan' } ;
1415const plan : Plan = { schema_version : 1 , issue : 1 , revision : 1 , summary : 'Two items' , questions : [ ] , items : [
1516 { id : 'P1' , title : 'First' , intent : 'Change a' , files : [ { path : 'a.ts' , kind : 'edit' , renamed_from : null , change : 'x' } ] , acceptance : [ { type : 'cmd' , text : 'npm test' } ] , depends_on : [ ] } ,
@@ -47,19 +48,19 @@ function setup(options: { manifests?: Record<string, ChangeManifest & { digest:
4748 } ,
4849 } ;
4950 const sources : ExecutionSources = { planContext : ( ) => context , issue : ( ) => ( { number : 1 , title : 'Issue' , body : 'Please fix' , comments : [ ] } ) , lessons : ( ) => [ ] , vendor : ( ) => 'claude' } ;
50- const prompts : string [ ] = [ ] , argv : ( readonly ( readonly string [ ] ) [ ] ) [ ] = [ ] ;
51+ const prompts : string [ ] = [ ] , argv : ( readonly ( readonly string [ ] ) [ ] ) [ ] = [ ] , owners : string [ ] = [ ] ;
5152 const deps = executionDeps ( store , workspace , ( input , prompt , ws ) => {
52- log . push ( `start ${ itemOf ( ws ) } ` ) ; prompts . push ( prompt ) ; argv . push ( input . approvedArgv ) ;
53+ log . push ( `start ${ itemOf ( ws ) } ` ) ; prompts . push ( prompt ) ; argv . push ( input . approvedArgv ) ; owners . push ( input . runnerOwner ) ;
5354 return { attemptId : input . attemptId , settled : Promise . resolve ( { attemptId : input . attemptId , context : input . context , exitCode : 0 , signal : null , stdout : 'done' , stderr : '' , ...options . exit ?. [ itemOf ( ws ) ] } ) , cancel : ( ) => undefined } ;
54- } , sources ) ;
55+ } , sources , RUNNER_OWNER ) ;
5556 const runner = new RunnerCoordinator ( store , deps ) ;
5657 cleanups . push ( async ( ) => { await runner . close ( ) ; store . close ( ) ; } ) ;
57- return { store, runner, executor : new ItemExecutor ( store , runner , sources ) , log, commits, prompts, argv } ;
58+ return { store, runner, executor : new ItemExecutor ( store , runner , sources ) , log, commits, prompts, argv, owners } ;
5859}
5960
6061describe ( 'item execution' , ( ) => {
6162 it ( 'runs items in order, commits each with trailers, and records owned ledger entries' , async ( ) => {
62- const { store, executor, log, commits, prompts, argv } = setup ( ) ;
63+ const { store, executor, log, commits, prompts, argv, owners } = setup ( ) ;
6364 expect ( await executor . runTask ( identity ) ) . toEqual ( { kind : 'executed' , items : [ 'P1' , 'P2' ] , unchanged : [ ] } ) ;
6465 expect ( commits . map ( c => [ c . item , c . baseHead . slice ( - 3 ) , c . trailers , c . paths , c . message ] ) ) . toEqual ( [
6566 [ 'P1' , '002' , { 'Plan-Item' : 'P1' , 'Plan-Revision' : 'r1' } , [ 'a.ts' ] , 'P1: First' ] ,
@@ -72,6 +73,7 @@ describe('item execution', () => {
7273 'materialize P2 @064' , 'snapshot P2 []' , 'start P2' , 'inspect P2 @064' , 'commit P2 -> 065' , 'release P2 after completed' ] ) ;
7374 expect ( prompts [ 0 ] ) . toContain ( '<plan_item_data>' ) ;
7475 expect ( argv [ 0 ] ) . toEqual ( [ [ 'npm' , 'test' ] ] ) ;
76+ expect ( owners [ 0 ] ) . toBe ( RUNNER_OWNER ) ;
7577 expect ( argv [ 1 ] ) . toEqual ( [ ] ) ;
7678 } ) ;
7779 it ( 'reports a planned-but-unchanged item without committing' , async ( ) => {
0 commit comments