@@ -2534,7 +2534,7 @@ it.layer(BaseTestLayer)("OrchestrationProjectionPipeline", (it) => {
25342534 } ) ,
25352535 ) ;
25362536
2537- it . effect ( "maintains shell summary fields across message and activity streams " , ( ) =>
2537+ it . effect ( "maintains shell summaries without reading message bodies " , ( ) =>
25382538 Effect . gen ( function * ( ) {
25392539 const projectionPipeline = yield * OrchestrationProjectionPipeline ;
25402540 const eventStore = yield * OrchestrationEventStore ;
@@ -2742,6 +2742,106 @@ it.layer(BaseTestLayer)("OrchestrationProjectionPipeline", (it) => {
27422742 updatedAt : "2026-03-01T08:00:05.000Z" ,
27432743 } ,
27442744 ] ) ;
2745+
2746+ // Summary refreshes must not decode message bodies or attachment metadata.
2747+ yield * sql `
2748+ UPDATE projection_thread_messages
2749+ SET attachments_json = '{not-json'
2750+ WHERE thread_id = 'thread-shell-summary'
2751+ ` ;
2752+ yield * sql `
2753+ INSERT INTO projection_pending_approvals (
2754+ request_id, thread_id, turn_id, status, decision, created_at, resolved_at
2755+ ) VALUES
2756+ ('summary-pending', 'thread-shell-summary', NULL, 'pending', NULL,
2757+ '2026-03-01T08:00:06.000Z', NULL),
2758+ ('summary-resolved', 'thread-shell-summary', NULL, 'resolved', 'accept',
2759+ '2026-03-01T08:00:06.000Z', '2026-03-01T08:00:06.000Z'),
2760+ ('summary-other-thread', 'thread-shell-summary-other', NULL, 'pending', NULL,
2761+ '2026-03-01T08:00:06.000Z', NULL)
2762+ ` ;
2763+ yield * sql `
2764+ INSERT INTO projection_thread_proposed_plans (
2765+ plan_id, thread_id, turn_id, plan_markdown, implemented_at,
2766+ implementation_thread_id, created_at, updated_at
2767+ ) VALUES (
2768+ 'summary-plan', 'thread-shell-summary', 'turn-shell-summary-1', '# Plan', NULL,
2769+ NULL, '2026-03-01T08:00:06.000Z', '2026-03-01T08:00:06.000Z'
2770+ )
2771+ ` ;
2772+
2773+ const refreshEvents = [
2774+ {
2775+ type : "thread.session-set" ,
2776+ eventId : EventId . make ( "evt-shell-summary-7" ) ,
2777+ aggregateKind : "thread" ,
2778+ aggregateId : ThreadId . make ( "thread-shell-summary" ) ,
2779+ occurredAt : "2026-03-01T08:00:07.000Z" ,
2780+ commandId : CommandId . make ( "cmd-shell-summary-7" ) ,
2781+ causationEventId : null ,
2782+ correlationId : CorrelationId . make ( "cmd-shell-summary-7" ) ,
2783+ metadata : { } ,
2784+ payload : {
2785+ threadId : ThreadId . make ( "thread-shell-summary" ) ,
2786+ session : {
2787+ threadId : ThreadId . make ( "thread-shell-summary" ) ,
2788+ status : "ready" ,
2789+ providerName : "codex" ,
2790+ runtimeMode : "approval-required" ,
2791+ activeTurnId : null ,
2792+ lastError : null ,
2793+ updatedAt : "2026-03-01T08:00:07.000Z" ,
2794+ } ,
2795+ } ,
2796+ } ,
2797+ {
2798+ type : "thread.turn-diff-completed" ,
2799+ eventId : EventId . make ( "evt-shell-summary-8" ) ,
2800+ aggregateKind : "thread" ,
2801+ aggregateId : ThreadId . make ( "thread-shell-summary" ) ,
2802+ occurredAt : "2026-03-01T08:00:08.000Z" ,
2803+ commandId : CommandId . make ( "cmd-shell-summary-8" ) ,
2804+ causationEventId : null ,
2805+ correlationId : CorrelationId . make ( "cmd-shell-summary-8" ) ,
2806+ metadata : { } ,
2807+ payload : {
2808+ threadId : ThreadId . make ( "thread-shell-summary" ) ,
2809+ turnId : TurnId . make ( "turn-shell-summary-1" ) ,
2810+ checkpointTurnCount : 1 ,
2811+ checkpointRef : CheckpointRef . make ( "refs/t3/checkpoints/thread-shell-summary/1" ) ,
2812+ status : "ready" ,
2813+ files : [ ] ,
2814+ assistantMessageId : MessageId . make ( "message-shell-summary-assistant" ) ,
2815+ completedAt : "2026-03-01T08:00:08.000Z" ,
2816+ } ,
2817+ } ,
2818+ ] satisfies ReadonlyArray < Parameters < typeof eventStore . append > [ 0 ] > ;
2819+
2820+ for ( const event of refreshEvents ) {
2821+ yield * appendAndProject ( event ) ;
2822+ const summary = yield * sql < {
2823+ readonly latestUserMessageAt : string | null ;
2824+ readonly pendingApprovalCount : number ;
2825+ readonly pendingUserInputCount : number ;
2826+ readonly hasActionableProposedPlan : number ;
2827+ } > `
2828+ SELECT
2829+ latest_user_message_at AS "latestUserMessageAt",
2830+ pending_approval_count AS "pendingApprovalCount",
2831+ pending_user_input_count AS "pendingUserInputCount",
2832+ has_actionable_proposed_plan AS "hasActionableProposedPlan"
2833+ FROM projection_threads
2834+ WHERE thread_id = 'thread-shell-summary'
2835+ ` ;
2836+ assert . deepEqual ( summary , [
2837+ {
2838+ latestUserMessageAt : "2026-03-01T08:00:02.000Z" ,
2839+ pendingApprovalCount : 1 ,
2840+ pendingUserInputCount : 1 ,
2841+ hasActionableProposedPlan : 1 ,
2842+ } ,
2843+ ] ) ;
2844+ }
27452845 } ) ,
27462846 ) ;
27472847
0 commit comments