1- import { describe , it } from "@executablemd/test-support/bdd" ;
1+ import { beforeEach , describe , it } from "@executablemd/test-support/bdd" ;
2+ import { journalBeforeEach , useJournalStream } from "@executablemd/test-support/failure-journal" ;
23import { ensureDir , readTextFile , rm , writeTextFile } from "@effectionx/fs" ;
34import { expect } from "@executablemd/test-support/expect" ;
45import { useComponentModuleLoader } from "@executablemd/test-support/host" ;
@@ -36,6 +37,7 @@ import PhaseSession, {
3637} from "../../../examples/adversarial-implementation/components/Phase/Session.ts" ;
3738
3839const pair = z . strictObject ( { kind : z . string ( ) , value : z . string ( ) } ) ;
40+ const OWNER = "packages/cli/tests/adversarial-session-continuity.test.ts" ;
3941const receipt = z . strictObject ( {
4042 schema : z . literal ( "phase-session.v2" ) ,
4143 agent : z . string ( ) ,
@@ -486,7 +488,11 @@ interface ReviewWorld {
486488 store : FakeStore ;
487489 delivery : Record < string , Json > ;
488490 asked : unknown [ ] ;
489- run ( source : string , props : Record < string , Json > ) : Operation < { ok : boolean ; text : string } > ;
491+ run (
492+ source : string ,
493+ props : Record < string , Json > ,
494+ stream ?: InMemoryStream ,
495+ ) : Operation < { ok : boolean ; text : string } > ;
490496}
491497
492498function * reviewWorld ( fake : FakeAcp , create = fake . create ) : Operation < ReviewWorld > {
@@ -507,7 +513,7 @@ function* reviewWorld(fake: FakeAcp, create = fake.create): Operation<ReviewWorl
507513 inputs : [ { path : "accepted.md" , content : "The original accepted behavior." } ] ,
508514 required : [ "independent-review" , "required-ci" , "main-health" ] ,
509515 } ;
510- function run ( source : string , props : Record < string , Json > ) {
516+ function run ( source : string , props : Record < string , Json > , stream ?: InMemoryStream ) {
511517 return scoped ( function * ( ) {
512518 yield * useHostFiles ( ) ;
513519 yield * useComponentModuleLoader ( ) ;
@@ -539,7 +545,12 @@ function* reviewWorld(fake: FakeAcp, create = fake.create): Operation<ReviewWorl
539545 const doc = join ( root , `document-${ randomUUID ( ) } .md` ) ;
540546 yield * writeTextFile ( doc , `---\nprops: {type: object}\n---\n${ source } ` ) ;
541547 const executed = yield * executeInstalled (
542- { path : doc , stream : new InMemoryStream ( ) , includes : [ components ] , props } ,
548+ {
549+ path : doc ,
550+ stream : stream ?? ( yield * useJournalStream ( doc ) ) ,
551+ includes : [ components ] ,
552+ props,
553+ } ,
543554 [ { components : agentIdentityComponents ( ) , * install ( ) { } } ] ,
544555 ) ;
545556 try {
@@ -576,6 +587,8 @@ const continuedRoleSource =
576587 '<Phase.Role role="implementor" session="controlled-owner" assignment={{...props.assignment,sessionEstablished:true}} />' ;
577588
578589describe ( "production workflow provider scope" , ( ) => {
590+ beforeEach ( journalBeforeEach ( OWNER ) ) ;
591+
579592 it ( "applies controls through each actual Claude role and retains them across cold reentry" , function * ( ) {
580593 for ( const role of [ "phase" , "foundation" , "preparation" , "delivery" ] ) {
581594 const fake = createFakeAcp ( ) ;
@@ -860,6 +873,8 @@ describe(
860873 "production independent review over the registered acpx factory" ,
861874 { sanitizeOps : false , sanitizeResources : false } ,
862875 ( ) => {
876+ beforeEach ( journalBeforeEach ( OWNER ) ) ;
877+
863878 it ( "configures the advertised exact Fable model and effort, and omits a null effort" , function * ( ) {
864879 for ( const effort of [ "high" , null ] ) {
865880 const fake = createFakeAcp ( ) ;
@@ -922,18 +937,22 @@ describe(
922937 ) ;
923938 const harness = yield * reviewWorld ( fake ) ;
924939 const attempt = join ( harness . root , "delivery" , "attempt" ) ;
925- const ran = yield * harness . run ( roleSource , {
926- delivery : harness . delivery ,
927- revision,
928- reviewer : {
929- provider : "claude" ,
930- model : "fable" ,
931- effort : variant === "refused" ? "high" : null ,
932- session : "independent" ,
940+ const ran = yield * harness . run (
941+ roleSource ,
942+ {
943+ delivery : harness . delivery ,
944+ revision,
945+ reviewer : {
946+ provider : "claude" ,
947+ model : "fable" ,
948+ effort : variant === "refused" ? "high" : null ,
949+ session : "independent" ,
950+ } ,
951+ choices : [ "fable" ] ,
952+ attempt,
933953 } ,
934- choices : [ "fable" ] ,
935- attempt,
936- } ) ;
954+ new InMemoryStream ( ) ,
955+ ) ;
937956 expect ( ran . ok ) . toBe ( true ) ;
938957 const settled = outcome . parse (
939958 JSON . parse ( yield * readTextFile ( join ( attempt , "outcome.json" ) ) ) ,
@@ -965,7 +984,7 @@ describe(
965984 const gate = closeGate ( fake ) ;
966985 const harness = yield * reviewWorld ( fake , gate . create ) ;
967986 const task = yield * spawn ( ( ) =>
968- harness . run ( reviewSource , { delivery : harness . delivery , revision } ) ,
987+ harness . run ( reviewSource , { delivery : harness . delivery , revision } , new InMemoryStream ( ) ) ,
969988 ) ;
970989 yield * gate . reached . operation ;
971990 expect ( fake . turns ) . toHaveLength ( 1 ) ;
@@ -1014,7 +1033,7 @@ describe(
10141033 const gate = closeGate ( fake ) ;
10151034 const harness = yield * reviewWorld ( fake , gate . create ) ;
10161035 const task = yield * spawn ( ( ) =>
1017- harness . run ( reviewSource , { delivery : harness . delivery , revision } ) ,
1036+ harness . run ( reviewSource , { delivery : harness . delivery , revision } , new InMemoryStream ( ) ) ,
10181037 ) ;
10191038 yield * gate . reached . operation ;
10201039 expect ( fake . turns . map ( ( _ , index ) => agentOf ( fake , index ) ) ) . toEqual ( [ "claude" ] ) ;
@@ -1072,7 +1091,11 @@ describe(
10721091 fake . configuration ( catalog ( [ "fable" , "gpt-6-astra" ] ) ) ;
10731092 fake . script ( { reply : "" , cancelled : true } ) ;
10741093 const harness = yield * reviewWorld ( fake ) ;
1075- const ran = yield * harness . run ( reviewSource , { delivery : harness . delivery , revision } ) ;
1094+ const ran = yield * harness . run (
1095+ reviewSource ,
1096+ { delivery : harness . delivery , revision } ,
1097+ new InMemoryStream ( ) ,
1098+ ) ;
10761099 expect ( ran . ok ) . toBe ( true ) ;
10771100 expect ( fake . turns . map ( ( _ , index ) => agentOf ( fake , index ) ) ) . toEqual ( [ "claude" ] ) ;
10781101 const attempt = join ( harness . delivery . directory as string , `review-${ revision } ` ) ;
@@ -1104,13 +1127,17 @@ describe(
11041127 ) ;
11051128 function * reviewAt ( sha : string ) {
11061129 const attempt = join ( harness . delivery . directory as string , `review-${ sha } ` ) ;
1107- const ran = yield * harness . run ( roleSource , {
1108- delivery : harness . delivery ,
1109- revision : sha ,
1110- reviewer,
1111- choices : [ "fable" ] ,
1112- attempt,
1113- } ) ;
1130+ const ran = yield * harness . run (
1131+ roleSource ,
1132+ {
1133+ delivery : harness . delivery ,
1134+ revision : sha ,
1135+ reviewer,
1136+ choices : [ "fable" ] ,
1137+ attempt,
1138+ } ,
1139+ new InMemoryStream ( ) ,
1140+ ) ;
11141141 return { ran, attempt } ;
11151142 }
11161143 fake . configuration ( catalog ( [ "claude-opus" ] ) ) ;
@@ -1155,7 +1182,11 @@ describe(
11551182 } ) ;
11561183 fake . closeFailure = new Error ( "the review provider would not close" ) ;
11571184 const harness = yield * reviewWorld ( fake ) ;
1158- const ran = yield * harness . run ( reviewSource , { delivery : harness . delivery , revision } ) ;
1185+ const ran = yield * harness . run (
1186+ reviewSource ,
1187+ { delivery : harness . delivery , revision } ,
1188+ new InMemoryStream ( ) ,
1189+ ) ;
11591190 expect ( ran . ok ) . toBe ( false ) ;
11601191 expect ( ran . text ) . toContain ( "agent provider teardown failed" ) ;
11611192 expect ( fake . closes ) . toContain ( "scope teardown" ) ;
0 commit comments