@@ -144,7 +144,7 @@ interface FileEffect {
144144 * transaction are invisible here until that transaction commits, so this
145145 * reports what has been *published* rather than what some handle is holding.
146146 */
147- function committedEffects ( path : string ) : FileEffect [ ] {
147+ function committedEffects ( path : string ) : Operation < FileEffect [ ] > {
148148 return readRunDatabase ( path , ( database ) => {
149149 const rows = database
150150 . prepare ( "SELECT event_id AS id, record FROM journal_events ORDER BY sequence" )
@@ -163,15 +163,15 @@ function committedEffects(path: string): FileEffect[] {
163163}
164164
165165/** The run's retained status, as a second connection sees it. */
166- function committedStatus ( path : string ) : string {
166+ function committedStatus ( path : string ) : Operation < string > {
167167 return readRunDatabase ( path , ( database ) => {
168168 const row = database . prepare ( "SELECT status FROM workflow_run WHERE id = 1" ) . get ( ) ;
169169 return String ( row ?. [ "status" ] ) ;
170170 } ) ;
171171}
172172
173173/** The current Workspace root, as a second connection sees it. */
174- function committedRoot ( path : string ) : string {
174+ function committedRoot ( path : string ) : Operation < string > {
175175 return readRunDatabase ( path , ( database ) => {
176176 const row = database . prepare ( "SELECT current_root_id AS root FROM workspace_state" ) . get ( ) ;
177177 return String ( row ?. [ "root" ] ) ;
@@ -193,7 +193,7 @@ interface ExecutionRow {
193193 * them by identity is what separates "an execution was closed" from "*this*
194194 * execution was closed".
195195 */
196- function committedExecutions ( path : string ) : ExecutionRow [ ] {
196+ function committedExecutions ( path : string ) : Operation < ExecutionRow [ ] > {
197197 return readRunDatabase ( path , ( database ) =>
198198 database
199199 . prepare (
@@ -283,12 +283,12 @@ function signalledRun(
283283 yield * when (
284284 function * ( ) {
285285 expect ( exists ( path ) ) . toBe ( true ) ;
286- expect ( committedEffects ( path ) . length ) . toBeGreaterThanOrEqual ( reached ) ;
286+ expect ( ( yield * committedEffects ( path ) ) . length ) . toBeGreaterThanOrEqual ( reached ) ;
287287 } ,
288288 { timeout : 60_000 } ,
289289 ) ;
290- const before = committedEffects ( path ) ;
291- const rootBefore = committedRoot ( path ) ;
290+ const before = yield * committedEffects ( path ) ;
291+ const rootBefore = yield * committedRoot ( path ) ;
292292 process . kill ( child . pid , signal ) ;
293293 const status = yield * child . join ( ) ;
294294
@@ -320,11 +320,11 @@ describe("Tier WFX — a killed workflow run resumes from its frontier", () => {
320320
321321 // Nothing ran after the signal, so the run is still `running`: no status
322322 // was published and no execution record was closed.
323- expect ( committedStatus ( path ) ) . toBe ( "running" ) ;
323+ expect ( yield * committedStatus ( path ) ) . toBe ( "running" ) ;
324324
325325 // The killed owner's execution, by its own identity. It is open, because
326326 // closing one is work and the signal left no opportunity to do any.
327- const abandoned = committedExecutions ( path ) ;
327+ const abandoned = yield * committedExecutions ( path ) ;
328328 expect ( abandoned ) . toHaveLength ( 1 ) ;
329329 expect ( abandoned [ 0 ] ?. stopped ) . toBe ( false ) ;
330330 const owner = abandoned [ 0 ] ?. executionId ;
@@ -338,9 +338,9 @@ describe("Tier WFX — a killed workflow run resumes from its frontier", () => {
338338 expect ( resumed . code ) . toBe ( 0 ) ;
339339 expect ( resumed . stderr ) . toContain ( `workflow run: ${ RUN_ID } ` ) ;
340340 expect ( resumed . stderr ) . toContain ( "workflow status: completed" ) ;
341- expect ( committedStatus ( path ) ) . toBe ( "completed" ) ;
341+ expect ( yield * committedStatus ( path ) ) . toBe ( "completed" ) ;
342342
343- const after = committedEffects ( path ) ;
343+ const after = yield * committedEffects ( path ) ;
344344
345345 // Every effect the kill left committed is still there, by its own event
346346 // id and in the same order: the resume replayed them rather than
@@ -358,13 +358,13 @@ describe("Tier WFX — a killed workflow run resumes from its frontier", () => {
358358
359359 // The resume continued from the root the last committed effect left, so
360360 // the frontier moved on rather than starting again.
361- expect ( committedRoot ( path ) ) . not . toBe ( killed . rootBefore ) ;
361+ expect ( yield * committedRoot ( path ) ) . not . toBe ( killed . rootBefore ) ;
362362
363363 // And the killed owner's own execution — that exact one, not merely some
364364 // execution — was closed as interrupted, saying what became of the attempt
365365 // the signal ended. The resume's execution is a different one, and it
366366 // completed.
367- const settled = committedExecutions ( path ) ;
367+ const settled = yield * committedExecutions ( path ) ;
368368 expect ( settled ) . toHaveLength ( 2 ) ;
369369 expect ( settled [ 0 ] ?. executionId ) . toBe ( owner ) ;
370370 expect ( settled [ 0 ] ?. stopped ) . toBe ( true ) ;
@@ -397,8 +397,8 @@ describe("Tier WFX — a killed workflow run resumes from its frontier", () => {
397397 // anything resumes: the process that was interrupted settled its own run.
398398 // A kill leaves `running` with an open execution for the next owner to
399399 // reconcile; a Ctrl-C leaves the outcome already published.
400- expect ( committedStatus ( path ) ) . toBe ( "interrupted" ) ;
401- const closed = committedExecutions ( path ) ;
400+ expect ( yield * committedStatus ( path ) ) . toBe ( "interrupted" ) ;
401+ const closed = yield * committedExecutions ( path ) ;
402402 expect ( closed ) . toHaveLength ( 1 ) ;
403403 expect ( closed [ 0 ] ?. stopped ) . toBe ( true ) ;
404404 expect ( closed [ 0 ] ?. stopStatus ) . toBe ( "interrupted" ) ;
@@ -417,18 +417,18 @@ describe("Tier WFX — a killed workflow run resumes from its frontier", () => {
417417
418418 expect ( resumed . code ) . toBe ( 0 ) ;
419419 expect ( resumed . stderr ) . toContain ( "workflow status: completed" ) ;
420- expect ( committedStatus ( path ) ) . toBe ( "completed" ) ;
420+ expect ( yield * committedStatus ( path ) ) . toBe ( "completed" ) ;
421421
422422 // Nothing the interruption had already committed was performed again, by
423423 // event id and in order, and the document's effects appear exactly once.
424- const after = committedEffects ( path ) ;
424+ const after = yield * committedEffects ( path ) ;
425425 expect ( after . slice ( 0 , interrupted . before . length ) ) . toEqual ( interrupted . before ) ;
426426 expect ( after ) . toHaveLength ( HELD_EFFECTS ) ;
427427 expect ( new Set ( after . map ( ( effect ) => effect . name ) ) . size ) . toBe ( HELD_EFFECTS ) ;
428428
429429 // The interrupted execution stays closed as it was, and the resume's is a
430430 // second, different one.
431- const settled = committedExecutions ( path ) ;
431+ const settled = yield * committedExecutions ( path ) ;
432432 expect ( settled ) . toHaveLength ( 2 ) ;
433433 expect ( settled [ 0 ] ?. executionId ) . toBe ( owner ) ;
434434 expect ( settled [ 0 ] ?. stopStatus ) . toBe ( "interrupted" ) ;
@@ -448,8 +448,8 @@ describe("Tier WFX — a killed workflow run resumes from its frontier", () => {
448448 document : "flows/holding.md" ,
449449 reached : HELD_EFFECTS ,
450450 } ) ;
451- expect ( committedStatus ( path ) ) . toBe ( "running" ) ;
452- expect ( committedExecutions ( path ) ) . toHaveLength ( 1 ) ;
451+ expect ( yield * committedStatus ( path ) ) . toBe ( "running" ) ;
452+ expect ( yield * committedExecutions ( path ) ) . toHaveLength ( 1 ) ;
453453
454454 const options = {
455455 cwd : fixture . repository ,
@@ -478,14 +478,14 @@ describe("Tier WFX — a killed workflow run resumes from its frontier", () => {
478478 // The loser was refused before it could begin anything: the run holds the
479479 // killed owner's execution and the winner's, and no third. A refusal that
480480 // still recorded an execution would be a second owner advancing the run.
481- const settled = committedExecutions ( path ) ;
481+ const settled = yield * committedExecutions ( path ) ;
482482 expect ( settled ) . toHaveLength ( 2 ) ;
483483 expect ( settled [ 0 ] ?. stopStatus ) . toBe ( "interrupted" ) ;
484484 expect ( settled [ 1 ] ?. stopStatus ) . toBe ( "completed" ) ;
485485
486486 // And one winner means one set of effects.
487- expect ( committedStatus ( path ) ) . toBe ( "completed" ) ;
488- const after = committedEffects ( path ) ;
487+ expect ( yield * committedStatus ( path ) ) . toBe ( "completed" ) ;
488+ const after = yield * committedEffects ( path ) ;
489489 expect ( after ) . toHaveLength ( HELD_EFFECTS ) ;
490490 expect ( new Set ( after . map ( ( effect ) => effect . name ) ) . size ) . toBe ( HELD_EFFECTS ) ;
491491 } ) ;
0 commit comments