use crate::inspect::smp::services::SmpServiceConsumerHypothesis;
use crate::inspect::smp::world::SmpSaveCompanyChairmanAnalysisReport;

pub(super) fn build_pending_bonus_hypothesis(
    analysis: &SmpSaveCompanyChairmanAnalysisReport,
) -> SmpServiceConsumerHypothesis {
    SmpServiceConsumerHypothesis {
        label: "pending region bonus service path".to_string(),
        status: if analysis.region_record_triplets.is_some() {
            "highest_priority_static_mapping_target".to_string()
        } else {
            "possible_consumer_family".to_string()
        },
        candidate_consumers: vec![
            "0x004358d0 pending region bonus service owner".to_string(),
            "0x00420030 / 0x00420280 city-connection peer probes".to_string(),
            "0x0047efe0 placed-structure linked-company resolver".to_string(),
        ],
        evidence: vec![
            "atlas already bounds this owner as the direct consumer of [region+0x276], [region+0x302], and [region+0x316]".to_string(),
            "the new region trace already proves the record envelope and profile subcollection, so the remaining gap is the separate persisted latch seam rather than the service owner".to_string(),
            "the neighboring region-profile summary/display strip is now grounded as rebuild-only follow-on work: 0x00420410 and 0x004204c0 walk the restored profile collection [region+0x37f], resolve backing candidates through 0x00412b70, and then rebuild [region+0x2f6/+0x2fa/+0x2fe] plus cached-selector display strings [region+0x2f2] from candidate bytes [candidate+0xba/+0xbb] rather than reading persisted region-owned copies".to_string(),
            "direct disassembly now shows 0x004358d0 calling 0x00420030 twice plus 0x00420280, resolving the linked company through 0x0047efe0, posting company stat slot 4, and then clearing [region+0x276] while stamping [region+0x302] or [region+0x316]".to_string(),
            "that same direct disassembly now also tightens the branch meaning: the linked-company branch formats the localized region-name notice from [region+0x356], posts it through 0x004554e0 and 0x0042a080, clears [region+0x276], and stamps [region+0x302]=1, while the fallback branch only runs when [region+0x316]==0 and then flips that one-shot latch to 1 before emitting its alternate notice".to_string(),
            "the checked-in constructor owner 0x00421200 now also proves these latches are initialized locally at record construction time, which narrows the remaining gap to post-construction restore or rebuild rather than basic field identity".to_string(),
        ],
        blockers: vec![
            "restore seam that re-seeds [region+0x25e] and clears [region+0x302/+0x316] between service cycles".to_string(),
            "stable region id or class discriminator".to_string(),
        ],
    }
}
