@@ -554,7 +554,6 @@ export const makePlaybookStore = Effect.gen(function* () {
554554 workspaceRoot : string ,
555555 name : string ,
556556 key : string ,
557- crewInstanceId ?: string ,
558557 ) {
559558 const rows = yield * sql < {
560559 request_json : string ;
@@ -565,16 +564,19 @@ export const makePlaybookStore = Effect.gen(function* () {
565564 if (
566565 request [ 0 ] !== "start" ||
567566 ! recordedPath ||
568- path . basename ( recordedPath , ".yaml" ) !== name . replace ( / \. y a m l $ / , "" ) ||
569- ( request [ 2 ] ?? null ) !== ( crewInstanceId ?? null )
567+ path . basename ( recordedPath , ".yaml" ) !== name . replace ( / \. y a m l $ / , "" )
570568 )
571569 return yield * playbookError (
572570 "request_conflict" ,
573571 "This client_request_id belongs to a different operation. Use a new key for a new operation." ,
574572 ) ;
575- return { definitionPath : recordedPath } ;
573+ // Before runtime assignees, starts could include the originating Crew ID.
574+ // Preserve that legacy shape only for retries of the original unassigned start.
575+ const legacyRequest =
576+ request . length === 3 && typeof request [ 2 ] === "string" ? rows [ 0 ] . request_json : undefined ;
577+ return { definitionPath : recordedPath , legacyRequest } ;
576578 }
577- return yield * definitionPathFor ( workspaceRoot , name ) ;
579+ return { ... ( yield * definitionPathFor ( workspaceRoot , name ) ) , legacyRequest : undefined } ;
578580 } , Effect . mapError ( storageError ) ) ;
579581
580582 /** Reads a live definition without touching run state: no permit, no SQL, no revision bump. */
@@ -688,12 +690,16 @@ export const makePlaybookStore = Effect.gen(function* () {
688690 key : string ,
689691 assignee ?: string ,
690692 ) {
691- const { definitionPath } = yield * startDefinitionPathFor ( owner , workspaceRoot , name , key ) ;
692- const request = encodeRequest (
693- assignee === undefined
694- ? [ "start" , definitionPath ]
695- : [ "start" , definitionPath , null , assignee ] ,
693+ const { definitionPath, legacyRequest } = yield * startDefinitionPathFor (
694+ owner ,
695+ workspaceRoot ,
696+ name ,
697+ key ,
696698 ) ;
699+ const request =
700+ assignee === undefined
701+ ? ( legacyRequest ?? encodeRequest ( [ "start" , definitionPath ] ) )
702+ : encodeRequest ( [ "start" , definitionPath , null , assignee ] ) ;
697703 return yield * Effect . gen ( function * ( ) {
698704 yield * cancelOrphans ( ) ;
699705 const previous = yield * replay ( owner , key , request ) ;
@@ -1077,14 +1083,6 @@ export const makePlaybookStore = Effect.gen(function* () {
10771083 permit . withPermits ( 1 ) ,
10781084 ) ;
10791085 } , Effect . mapError ( storageError ) ) ;
1080- /** A Crew's active run with its saved progress, or null. */
1081- const activeRunForCrew = Effect . fn ( "PlaybookStore.activeRunForCrew" ) ( function * (
1082- crewInstanceId : string ,
1083- ) {
1084- const rows = yield * sql < RunRow > `SELECT * FROM j5_playbook_run
1085- WHERE crew_instance_id = ${ crewInstanceId } AND status = 'active' LIMIT 1` ;
1086- return rows [ 0 ] ? yield * view ( fromRow ( rows [ 0 ] ) ) : null ;
1087- } , Effect . mapError ( storageError ) ) ;
10881086 const activeRunSummaries = Effect . fn ( "PlaybookStore.activeRunSummaries" ) ( function * (
10891087 ownerThreadIds : ReadonlyArray < ThreadId > ,
10901088 ) {
@@ -1156,7 +1154,6 @@ export const makePlaybookStore = Effect.gen(function* () {
11561154 pendingLandings,
11571155 resolveLanding,
11581156 cancelForCrew,
1159- activeRunForCrew,
11601157 activeRunSummaries,
11611158 } ;
11621159} ) ;
0 commit comments