>}> */ public static function build(): array { $keys = ['business_summary','services_products','locations','hours','policies','contact_actions','page_summaries','answerable_questions','ai_file_entries','missing_answers']; $out = []; foreach ($keys as $key) $out[$key] = ['status' => 'not_found', 'facts' => []]; $map = ['about'=>'business_summary','service'=>'services_products','product'=>'services_products','location'=>'locations','legal'=>'policies','contact'=>'contact_actions']; $posts = get_posts(['post_type'=>['page','post'],'post_status'=>'publish','posts_per_page'=>50,'orderby'=>'ID','order'=>'ASC']); foreach ($posts as $post) { if (!$post instanceof WP_Post || !TheDotDevAgenticBridge_Content_Policy::is_manageable_preview_post((int)$post->ID)) continue; $config = TheDotDevAgenticBridge_Content_Metadata::effective_config_for_post($post); if (($config['inclusionMode'] ?? '') === TheDotDevAgenticBridge_Content_Metadata::INCLUSION_EXCLUDE) continue; $intent=(string)($config['intent']??'general_information'); $base=['sourceTitle'=>(string)$post->post_title,'sourceId'=>(int)$post->ID,'sourceUrl'=>get_permalink($post),'modifiedAt'=>get_post_modified_time('c',true,$post),'intent'=>$intent,'intentLabel'=>TheDotDevAgenticBridge_Content_Metadata::intent_label($intent)]; $summary=trim((string)($config['agentSummary']??'')); if ($summary !== '') { self::add($out,'page_summaries',$base+['text'=>$summary]); if(isset($map[$intent])) self::add($out,$map[$intent],$base+['text'=>$summary]); } foreach (TheDotDevAgenticBridge_Controlled_Answerable_Questions::records_for_post((int)$post->ID) as $record) { if (($record['state']??'') !== 'APPROVED' || trim((string) ($record['answer'] ?? '')) === '') continue; self::add($out,'answerable_questions',$base+['text'=>(string)($record['answer']??''),'question'=>(string)($record['question']??''),'recordType'=>(string)($record['type']??''),'recordId'=>(string)($record['id']??'')]); } } foreach (['business_summary'=>'Business summary','services_products'=>'Services or products','locations'=>'Locations or service area','hours'=>'Hours or availability','policies'=>'Policies','contact_actions'=>'Contact or actions'] as $key=>$label) if($out[$key]['facts']===[]) self::add($out,'missing_answers',['text'=>$label,'status'=>'not_found']); return $out; } private static function add(array &$out,string $key,array $fact): void { $out[$key]['facts'][]=$fact; $out[$key]['status']='found'; } }