@@ -1442,22 +1442,35 @@ describe("compaction-safeguard recent-turn preservation", () => {
14421442 "## Exact identifiers" ,
14431443 "None." ,
14441444 ] . join ( "\n" ) ;
1445+ const prefixSummary = ( pendingAsk ?: string ) =>
1446+ [
1447+ "## Original Request" ,
1448+ latestAsk ,
1449+ "## Early Progress" ,
1450+ "Validated the provider boxes." ,
1451+ "## Context for Suffix" ,
1452+ "The retained suffix owns continuation state." ,
1453+ ...( pendingAsk ? [ "## Pending user asks" , pendingAsk ] : [ ] ) ,
1454+ ] . join ( "\n" ) ;
14451455 const historySummary = structuredSummary ( "combine the provider boxes after migration" ) ;
1446- const splitSummary = structuredSummary ( "None." ) ;
1447- const params = {
1448- summary : splitSummary ,
1449- sourceSummaries : [ historySummary , splitSummary ] ,
1450- identifiers : [ ] ,
1451- latestAsk,
1452- } ;
1456+ const structuralSummary = structuredSummary ( "None." ) ;
1457+ const auditRetained = ( retainedTurnSummary : string ) =>
1458+ auditSummaryQuality ( {
1459+ summary : `${ structuralSummary } \n\n${ retainedTurnSummary } ` ,
1460+ sourceSummaries : [ historySummary , retainedTurnSummary ] ,
1461+ identifiers : [ ] ,
1462+ latestAsk,
1463+ retainedTurnSummary,
1464+ } ) ;
14531465
1454- expect ( auditSummaryQuality ( { ... params , retainedTurnSummary : splitSummary } ) ) . toEqual ( {
1466+ expect ( auditRetained ( prefixSummary ( ) ) ) . toEqual ( {
14551467 ok : true ,
14561468 reasons : [ ] ,
14571469 } ) ;
1458- expect (
1459- auditSummaryQuality ( { ...params , retainedTurnSummary : historySummary } ) . reasons ,
1460- ) . toContain ( "retained_turn_ask_marked_pending" ) ;
1470+ expect ( auditRetained ( historySummary ) . reasons ) . toContain ( "retained_turn_ask_marked_pending" ) ;
1471+ expect ( auditRetained ( prefixSummary ( latestAsk ) ) . reasons ) . toContain (
1472+ "retained_turn_ask_marked_pending" ,
1473+ ) ;
14611474 } ) ;
14621475
14631476 it ( "dedupes pure-hex identifiers across case variants" , ( ) => {
@@ -3228,22 +3241,19 @@ describe("compaction-safeguard recent-turn preservation", () => {
32283241 mockSummarizeInStages . mockReset ( ) ;
32293242 const latestAsk = "combine the provider boxes into one completed artifact" ;
32303243 const identifier = "/tmp/pr130620/live/marker" ;
3231- const structuredSummary = ( pendingAsk : string , openTodo : string ) =>
3244+ const prefixSummary = ( pendingAsk ? : string ) =>
32323245 [
3233- "## Decisions" ,
3234- "Keep the provider-box work active." ,
3235- "## Open TODOs" ,
3236- openTodo ,
3237- "## Constraints/Rules" ,
3238- "Preserve exact identifiers." ,
3239- "## Pending user asks" ,
3240- pendingAsk ,
3241- "## Exact identifiers" ,
3242- identifier ,
3246+ "## Original Request" ,
3247+ latestAsk ,
3248+ "## Early Progress" ,
3249+ "The RCA is complete." ,
3250+ "## Context for Suffix" ,
3251+ `Implementation remains. Preserve ${ identifier } .` ,
3252+ ...( pendingAsk ? [ "## Pending user asks" , pendingAsk ] : [ ] ) ,
32433253 ] . join ( "\n" ) ;
32443254 mockSummarizeInStages
3245- . mockResolvedValueOnce ( summaryResult ( structuredSummary ( latestAsk , "Implement the repair." ) ) )
3246- . mockResolvedValueOnce ( summaryResult ( structuredSummary ( "None." , "Implement the repair." ) ) ) ;
3255+ . mockResolvedValueOnce ( summaryResult ( prefixSummary ( latestAsk ) ) )
3256+ . mockResolvedValueOnce ( summaryResult ( prefixSummary ( ) ) ) ;
32473257
32483258 const sessionManager = stubSessionManager ( ) ;
32493259 setCompactionSafeguardRuntime ( sessionManager , {
@@ -3284,7 +3294,7 @@ describe("compaction-safeguard recent-turn preservation", () => {
32843294 const retry = requireRecord ( mockCallArg ( mockSummarizeInStages , 1 ) ) ;
32853295 expect ( retry . customInstructions ) . toContain ( "retained_turn_ask_marked_pending" ) ;
32863296 expect ( finalSummary ) . toContain ( `## Latest user request context\n${ JSON . stringify ( latestAsk ) } ` ) ;
3287- expect ( finalSummary ) . toContain ( "## Open TODOs\nImplement the repair ." ) ;
3297+ expect ( finalSummary ) . toContain ( "### Context for Suffix\nImplementation remains ." ) ;
32883298 expect ( finalSummary ) . toContain ( "## Pending user asks\nNone." ) ;
32893299 expect ( finalSummary ) . not . toContain ( `## Pending user asks\n${ latestAsk } ` ) ;
32903300 expectCanonicalSummaryHeadingsOnce ( finalSummary ) ;
0 commit comments