@@ -1315,7 +1315,10 @@ export function scopedReplanYardstickReversal(decision: JsonObject) {
13151315 return { cue, fields, path : [ ...REPLAN_CONTEXT_PATH , "explore_basis" , "work_yardsticks" , index ] } ;
13161316}
13171317
1318- function requiredManagerAgenda ( value : unknown , requiredReads : unknown [ ] , deferredPointer ?: string ) : JsonObject | undefined {
1318+ const MANAGER_AGENDA_FIELDS = [ "count_unit" , "incoming_count" , "outgoing_count" , "omitted_count" ,
1319+ "return_attention" , "planning_request" , "scan_complete" , "unavailable_count" , "observed_at" , "read_command" , "instruction" ] ;
1320+
1321+ function requiredManagerAgenda ( value : unknown , requiredReads : unknown [ ] , deferredAgendaPointer ?: string ) : JsonObject | undefined {
13191322 const { content, ...read } = jsonObject ( value ) ?? { } ;
13201323 const source = jsonObject ( content ) , agenda = jsonObject ( source ?. unfinished_delegations ) ;
13211324 if ( read . source !== "turn_start_capability_hook" || read . kind !== "operator_inbox"
@@ -1325,14 +1328,10 @@ function requiredManagerAgenda(value: unknown, requiredReads: unknown[], deferre
13251328 || ! agenda || agenda . read_command !== read . command || agenda . count_unit !== "request"
13261329 || agenda . scan_complete !== true || agenda . unavailable_count !== 0
13271330 || ! requiredReads . some ( required => isDeepStrictEqual ( required , read ) ) ) return undefined ;
1328- // A projected agenda keeps its counts and return cues at this exact source;
1329- // only its rows move to the pinned detail capture.
1330- const deferred = deferredPointer !== undefined && agenda . supporting_material_pointer === deferredPointer
1331- && ! Object . hasOwn ( agenda , "items" ) ;
1332- if ( ( ! deferred && ! Array . isArray ( agenda . items ) )
1333- || ! known ( agenda , [ "count_unit" , deferred ? "supporting_material_pointer" : "items" , "incoming_count" , "outgoing_count" , "omitted_count" ,
1334- "return_attention" , "planning_request" , "scan_complete" , "unavailable_count" , "observed_at" , "read_command" , "instruction" ] ) ) return undefined ;
1335- return agenda ;
1331+ const inline = Array . isArray ( agenda . items ) && known ( agenda , [ ...MANAGER_AGENDA_FIELDS , "items" ] ) ;
1332+ const deferred = deferredAgendaPointer !== undefined && agenda . supporting_material_pointer === deferredAgendaPointer
1333+ && known ( agenda , [ ...MANAGER_AGENDA_FIELDS , "supporting_material_pointer" ] ) ;
1334+ return inline || deferred ? agenda : undefined ;
13361335}
13371336
13381337/** A pending Manager Inbox read already delivers these scoped request rows. */
@@ -1348,6 +1347,7 @@ function managerAgendaOpeningFields(agenda: JsonObject | undefined): string[] |
13481347 || ( Array . isArray ( items ) && ( incoming + outgoing !== items . length + omitted
13491348 || Buffer . byteLength ( JSON . stringify ( items ) , "utf8" ) < 2048 ) ) ) return undefined ;
13501349 const fields = [ "incoming_count" , "outgoing_count" , "scan_complete" ] ;
1350+ if ( agenda . supporting_material_pointer !== undefined ) fields . push ( "supporting_material_pointer" ) ;
13511351 if ( omitted === 0 ) return fields ;
13521352 // A complete scan can have a bounded display. Preserve the omission count
13531353 // and reconciliation guidance while leaving the rows to the required read.
@@ -1473,11 +1473,15 @@ function initialContextReadGroups(context: JsonObject, decisionFields: readonly
14731473 ? channel . required_reads : [ ] ;
14741474 const work = [ "interaction_contract" , "agent_channel" , "work_context" ] ;
14751475 const sources = object ( channel ?. work_context ) ?. sources ;
1476- const sourceRows = Array . isArray ( sources ) ? sources . map ( ( source , index ) => ( {
1477- source, index, agenda : requiredManagerAgenda ( source , requiredInboxReads ,
1478- supportingSource && details && details . path === supportingSource . path && details . sha256 === supportingSource . sha256
1479- ? pointer ( [ ...work , "sources" , index , "content" , "unfinished_delegations" ] ) : undefined ) ,
1480- } ) ) : [ ] ;
1476+ const unreadPointers = at ( details , [ "unread_context_index" , "pointers" ] ) ;
1477+ const deferred = supportingSource && details ?. path === supportingSource . path
1478+ && details . sha256 === supportingSource . sha256 && Array . isArray ( unreadPointers )
1479+ ? new Set ( unreadPointers ) : undefined ;
1480+ const sourceRows = Array . isArray ( sources ) ? sources . map ( ( source , index ) => {
1481+ const path = pointer ( [ ...work , "sources" , index , "content" , "unfinished_delegations" ] ) ;
1482+ const agenda = requiredManagerAgenda ( source , requiredInboxReads , deferred ?. has ( path + "/items" ) ? path : undefined ) ;
1483+ return { source, index, agenda} ;
1484+ } ) : [ ] ;
14811485 const attentionSources = sourceRows . filter ( ( { agenda} ) => managerReturnAttention ( agenda ) ) ;
14821486 const requiredReadsPath = [ "interaction_contract" , "agent_channel" , "required_reads" ] ;
14831487 if ( ! attentionSources . length ) include ( ...requiredReadsPath ) ;
0 commit comments