use super::*;

#[test]
fn builds_periodic_company_service_trace_report_with_candidate_consumers() {
    let mut analysis = empty_analysis_report();
    analysis.selected_company_id = Some(7);
    analysis.placed_structure_record_triplets = Some(SmpSavePlacedStructureRecordTripletProbe {
        profile_family: analysis.profile_family.clone(),
        source_kind: "save-placed-structure-record-triplets".to_string(),
        semantic_family: "scenario-save-placed-structure-record-triplets".to_string(),
        records_tag_offset: 0,
        close_tag_offset: 0,
        record_count: 2,
        entries: vec![
            SmpSavePlacedStructureRecordTripletEntryProbe {
                record_index: 0,
                primary_name: "StationA".to_string(),
                secondary_name: "StationSetA".to_string(),
                name_tag_relative_offset: 0,
                policy_tag_relative_offset: 0,
                profile_tag_relative_offset: 0,
                policy_chunk_len: 0x1a,
                profile_chunk_len: 0x20,
                policy_f32_lane_0: 0.0,
                policy_f32_lane_1: 0.0,
                policy_f32_lane_2: 0.0,
                policy_f32_lane_3: 0.0,
                policy_f32_lane_4: 0.0,
                policy_reserved_dword: 0,
                policy_trailing_word: 0x0101,
                policy_trailing_word_hex: "0x0101".to_string(),
                profile_open_marker: 0x5dc1,
                profile_open_marker_hex: "0x00005dc1".to_string(),
                profile_repeated_primary_name: "StationA".to_string(),
                profile_repeated_secondary_name: "StationSetA".to_string(),
                profile_footer_relative_offset: 0,
                profile_footer_relative_offset_hex: "0x0".to_string(),
                profile_pre_footer_padding_len: 1,
                profile_pre_footer_padding_hex_bytes: vec!["0x01".to_string()],
                profile_companion_byte_u8: Some(1),
                profile_companion_byte_hex: Some("0x01".to_string()),
                profile_payload_dword: 0x0e373880,
                profile_payload_dword_hex: "0x0e373880".to_string(),
                profile_sentinel_i32: -1,
                profile_status_kind: "unset".to_string(),
                farm_growth_stage_index: None,
                profile_close_marker: 0x5dc2,
                profile_close_marker_hex: "0x00005dc2".to_string(),
            },
            SmpSavePlacedStructureRecordTripletEntryProbe {
                record_index: 1,
                primary_name: "StationB".to_string(),
                secondary_name: "StationSetB".to_string(),
                name_tag_relative_offset: 0,
                policy_tag_relative_offset: 0,
                profile_tag_relative_offset: 0,
                policy_chunk_len: 0x1a,
                profile_chunk_len: 0x20,
                policy_f32_lane_0: 0.0,
                policy_f32_lane_1: 0.0,
                policy_f32_lane_2: 0.0,
                policy_f32_lane_3: 0.0,
                policy_f32_lane_4: 0.0,
                policy_reserved_dword: 0,
                policy_trailing_word: 0x0101,
                policy_trailing_word_hex: "0x0101".to_string(),
                profile_open_marker: 0x5dc1,
                profile_open_marker_hex: "0x00005dc1".to_string(),
                profile_repeated_primary_name: "StationB".to_string(),
                profile_repeated_secondary_name: "StationSetB".to_string(),
                profile_footer_relative_offset: 0,
                profile_footer_relative_offset_hex: "0x0".to_string(),
                profile_pre_footer_padding_len: 1,
                profile_pre_footer_padding_hex_bytes: vec!["0x00".to_string()],
                profile_companion_byte_u8: Some(0),
                profile_companion_byte_hex: Some("0x00".to_string()),
                profile_payload_dword: 0x0e373500,
                profile_payload_dword_hex: "0x0e373500".to_string(),
                profile_sentinel_i32: -1,
                profile_status_kind: "unset".to_string(),
                farm_growth_stage_index: None,
                profile_close_marker: 0x5dc2,
                profile_close_marker_hex: "0x00005dc2".to_string(),
            },
        ],
        evidence: Vec::new(),
    });
    analysis.region_fixed_row_run_candidates = Some(SmpSaveRegionFixedRowRunCandidateProbe {
        profile_family: analysis.profile_family.clone(),
        source_kind: "save-region-fixed-row-run-candidates".to_string(),
        semantic_family: "scenario-save-region-fixed-row-run-candidates".to_string(),
        target_row_count: 4,
        target_row_stride: 0xbc,
        target_row_stride_hex: "0xbc".to_string(),
        scan_start_offset: 0,
        scan_start_offset_hex: "0x0".to_string(),
        scan_end_offset: 0x2000,
        scan_end_offset_hex: "0x2000".to_string(),
        candidates: vec![SmpSaveRegionFixedRowRunCandidate {
            count_offset: 0x40,
            count_offset_hex: "0x40".to_string(),
            row_count: 4,
            row_stride: 0xbc,
            row_stride_hex: "0xbc".to_string(),
            rows_offset: 0x5310,
            rows_offset_hex: "0x5310".to_string(),
            rows_end_offset: 0x5600,
            rows_end_offset_hex: "0x5600".to_string(),
            distance_to_region_metadata_tag: 0x80,
            distance_to_region_metadata_tag_hex: "0x80".to_string(),
            dword_lane_summaries: Vec::new(),
            shape_signature: "shape-a".to_string(),
            shape_family_signature: "family-a".to_string(),
            trailing_byte_zero_count: 4,
            trailing_byte_nonzero_count: 0,
            trailing_byte_distinct_value_count: 1,
            trailing_byte_sample_values_hex: vec!["0x00".to_string()],
            best_probable_density_lane_relative_offset_hex: Some("0x24".to_string()),
        }],
        evidence: Vec::new(),
    });
    analysis
        .company_entries
        .push(SmpSaveCompanyRecordAnalysisEntry {
            company_id: 7,
            name: "Test Company".to_string(),
            active: true,
            linked_chairman_profile_id: Some(3),
            outstanding_shares: 1000,
            debt: 0,
            bond_count: 0,
            live_bond_slots: Vec::new(),
            largest_live_bond_principal: None,
            highest_coupon_live_bond_principal: None,
            available_track_laying_capacity: Some(5),
            company_value_scalar_f32: 1.0,
            cached_share_support_scalar_f32: 1.0,
            cached_share_price_f32: 1.0,
            chairman_salary_baseline: 0,
            chairman_salary_current: 0,
            chairman_bonus_year: 0,
            chairman_bonus_amount: 0,
            founding_year: 1900,
            last_bankruptcy_year: 0,
            last_dividend_year: 0,
            preferred_locomotive_engine_type_raw_u8: 2,
            preferred_locomotive_engine_type_raw_hex: "0x02".to_string(),
            city_connection_latch: true,
            linked_transit_latch: false,
            linked_transit_autoroute_site_score_cache_refresh_absolute_counter: 0x31380,
            linked_transit_site_peer_cache_refresh_absolute_counter: 0x7ff80,
            linked_transit_route_anchor_entry_id: Some(77),
            linked_transit_route_anchor_fallback_counts: vec![3, 5, 8],
            merger_cooldown_year: 0,
            takeover_cooldown_year: 0,
            scalar_dword_candidates: Vec::new(),
            post_capacity_dword_candidates: Vec::new(),
            stat_band_root_0cfb_candidates: Vec::new(),
            stat_band_root_0d7f_candidates: Vec::new(),
            stat_band_root_1c47_candidates: Vec::new(),
        });

    let trace = build_periodic_company_service_trace_report(&analysis);
    assert_eq!(trace.selected_company_id, Some(7));
    assert_eq!(trace.atlas_candidate_consumers.len(), 9);
    assert_eq!(trace.known_bridge_helpers.len(), 84);
    assert_eq!(trace.next_owner_questions.len(), 5);
    assert_eq!(
        trace.linked_transit_shellless_readiness_status,
        "timed_cache_and_train_side_followons_grounded_site_cache_input_owners_missing"
    );
    assert_eq!(
        trace.linked_transit_minimum_persisted_identity_inputs.len(),
        5
    );
    assert_eq!(trace.linked_transit_live_rebuilt_cache_lanes.len(), 5);
    assert_eq!(trace.linked_transit_runtime_backed_input_families.len(), 18);
    assert_eq!(trace.linked_transit_remaining_owner_gaps.len(), 2);
    assert_eq!(trace.companies.len(), 1);
    assert_eq!(
        trace.companies[0].linked_transit_autoroute_site_score_cache_refresh_absolute_counter,
        0x31380
    );
    assert_eq!(
        trace.companies[0].linked_transit_site_peer_cache_refresh_absolute_counter,
        0x7ff80
    );
    assert_eq!(
        trace.peer_site_selector_candidate_owner_strip,
        "0x0045c150 -> 0x0045c310 -> 0x0045c36e -> 0x00456100 -> 0x00455b70"
    );
    assert_eq!(
        trace.peer_site_selector_candidate_persisted_tag_hex,
        "0x5dc1"
    );
    assert_eq!(
        trace.peer_site_selector_candidate_selector_lane,
        "[owner+0x23e]"
    );
    assert_eq!(
        trace.peer_site_selector_candidate_secondary_payload_lane,
        "[owner+0x242]"
    );
    assert!(
        trace
            .peer_site_selector_candidate_post_secondary_byte_status
            .contains("post-secondary discriminator byte")
    );
    assert_eq!(
        trace.peer_site_selector_candidate_class_identity_status,
        "grounded_direct_local_helper_strip"
    );
    assert_eq!(trace.peer_site_selector_candidate_helper_linkage.len(), 4);
    assert_eq!(
        trace
            .peer_site_selector_candidate_saved_payload_summaries
            .len(),
        2
    );
    assert_eq!(
        trace.peer_site_selector_candidate_saved_payload_summaries[0].profile_payload_dword_hex,
        "0x0e373500"
    );
    assert_eq!(
        trace.peer_site_selector_candidate_saved_payload_summaries[0].count,
        1
    );
    assert_eq!(
        trace.peer_site_selector_candidate_saved_payload_delta_summaries[0].delta_hex,
        "0x00000380"
    );
    assert_eq!(
        trace.peer_site_selector_candidate_saved_footer_padding_summaries[0].padding_len,
        1
    );
    assert_eq!(
        trace.peer_site_selector_candidate_saved_companion_byte_summaries[0].companion_byte_hex,
        "0x00"
    );
    assert_eq!(
        trace.peer_site_selector_candidate_saved_policy_trailing_word_summaries[0]
            .policy_trailing_word_hex,
        "0x0101"
    );
    assert_eq!(
        trace.peer_site_selector_candidate_saved_policy_trailing_word_summaries[0].count,
        2
    );
    assert_eq!(
        trace.peer_site_selector_candidate_saved_nonzero_companion_name_pair_summaries[0]
            .primary_name,
        "StationA"
    );
    assert!(
        trace
            .peer_site_selector_candidate_saved_nonzero_companion_building_family_overlap_summaries
            .is_empty()
    );
    assert_eq!(trace.peer_site_persisted_selector_bundle_fields.len(), 4);
    assert_eq!(trace.peer_site_rebuilt_transient_followon_fields.len(), 4);
    assert_eq!(
        trace.peer_site_shellless_minimum_persisted_identity_status,
        "name_pair_and_post_secondary_byte_minimum_identity_subset_child_runtime_bundle_rebuild_followon"
    );
    assert_eq!(
        trace
            .peer_site_shellless_minimum_persisted_identity_inputs
            .len(),
        5
    );
    assert_eq!(trace.peer_site_restore_input_fields.len(), 5);
    assert_eq!(trace.peer_site_runtime_input_fields.len(), 3);
    assert_eq!(
        trace.peer_site_runtime_reconstruction_status,
        "restore_subset_and_bring_up_reconstruct_runtime_subset"
    );
    assert_eq!(trace.peer_site_runtime_reconstruction_steps.len(), 4);
    assert_eq!(trace.near_city_acquisition_region_input_fields.len(), 5);
    assert_eq!(trace.near_city_acquisition_peer_input_fields.len(), 7);
    assert_eq!(trace.near_city_acquisition_company_input_fields.len(), 6);
    assert_eq!(
        trace.near_city_acquisition_shellless_readiness_status,
        "peer_and_company_inputs_grounded_runtime_projection_and_periodic_service_present"
    );
    assert_eq!(
        trace.near_city_acquisition_site_owner_company_projection_status,
        "best_effort_runtime_projection_from_save_collections_and_company_latches"
    );
    assert_eq!(
        trace.near_city_acquisition_site_self_id_projection_status,
        "live_meaning_grounded_reconstructible_from_collection_identity"
    );
    assert_eq!(
        trace.near_city_acquisition_site_cached_tri_lane_projection_status,
        "best_effort_runtime_projection_from_side_buffer_and_region_row_signatures"
    );
    assert_eq!(
        trace.near_city_acquisition_nontransport_persisted_source_status,
        "best_effort_runtime_projection_from_company_market_and_name_pair_alignment"
    );
    assert_eq!(
        trace
            .near_city_acquisition_nontransport_persisted_source_candidates
            .len(),
        5
    );
    assert_eq!(
        trace.near_city_acquisition_tri_lane_save_shape_family_status,
        "save_shape_family_candidates_present_fixed_offset_ruled_down"
    );
    assert_eq!(
        trace
            .near_city_acquisition_tri_lane_save_shape_family_candidates
            .len(),
        1
    );
    assert_eq!(
        trace.near_city_acquisition_tri_lane_save_shape_family_candidates[0].shape_family_signature,
        "family-a"
    );
    assert_eq!(
        trace.near_city_acquisition_tri_lane_live_service_status,
        "candidate_gate_grounded_runtime_projection_and_periodic_commit_present"
    );
    assert_eq!(
        trace.near_city_acquisition_candidate_subtype_projection_status,
        "cached_candidate_id_bridge_grounded_via_stream_load"
    );
    assert_eq!(
        trace.near_city_acquisition_backing_record_projection_status,
        "stream_load_callback_grounded_via_0x40ce60"
    );
    assert_eq!(
        trace
            .near_city_acquisition_tri_lane_live_owner_families
            .len(),
        5
    );
    assert_eq!(
        trace
            .near_city_acquisition_tri_lane_candidate_gate_fields
            .len(),
        5
    );
    assert_eq!(
        trace
            .near_city_acquisition_tri_lane_runtime_writer_roles
            .len(),
        5
    );
    assert_eq!(
        trace
            .near_city_acquisition_tri_lane_direct_caller_families
            .len(),
        5
    );
    assert_eq!(
        trace
            .near_city_acquisition_tri_lane_formula_input_lanes
            .len(),
        5
    );
    assert_eq!(trace.near_city_acquisition_projection_hypotheses.len(), 3);
    assert_eq!(
        trace.near_city_acquisition_projection_hypotheses[0].label,
        "site_owner_replay_from_post_load_refresh_self_id_reconstructible"
    );
    assert_eq!(
        trace.near_city_acquisition_projection_hypotheses[0].status,
        "ordinary_replay_and_stream_load_ruled_down_tuple_finalize_positive_path_grounded"
    );
    assert_eq!(
        trace.near_city_acquisition_projection_hypotheses[1].label,
        "site_cached_tri_lane_payload_or_restore_owner"
    );
    assert_eq!(
        trace.near_city_acquisition_projection_hypotheses[1].status,
        "checked_in_save_seams_ruled_down_live_scoring_family_grounded_exact_semantics_open"
    );
    assert_eq!(
        trace.near_city_acquisition_projection_hypotheses[2].label,
        "cached_source_candidate_id_to_subtype_projection"
    );
    assert_eq!(
        trace.near_city_acquisition_projection_hypotheses[2].status,
        "grounded_stream_load_callback_0x40ce60"
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x004133b0"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x004134d0") && line.contains("0x0040f6d0"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00403ef3 / 0x00404489"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x0046f073 / 0x004707ff"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00444690 -> 0x004133b0")
                && line.contains("ordinary bring-up replay family"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00444467")
                && line.contains("0x00413280")
                && line.contains("0x004444d8")
                && line.contains("0x00481210")
                && line.contains("0x00444690"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("after 0x00444690 -> 0x004133b0")
                && line.contains("0x004134d0 / 0x0040f6d0 / 0x0040ef10"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("[site+0x27a]")
                && line.contains("0x0042125d")
                && line.contains("0x0040f793")
                && line.contains("0x0040dfec")
                && line.contains("0x004269e4")
                && line.contains("0x00426a44..0x00426a90")
                && line.contains("0x00426ad8"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x0040ee10")
                && line.contains("[site+0x3cc]")
                && line.contains("0x0040e360..0x0040edf6")
                && line.contains("[site+0x2a8]")
                && line.contains("[site+0x2a4]")
                && line.contains("[site+0x276]")
                && line.contains("0x00480710")
                && line.contains("0x00426b10")
                && line.contains("0x00455860")
                && line.contains("reads/queries"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x004134d0")
                && line.contains("0x00518900")
                && line.contains("0x0040f6d0")
                && line.contains("[site+0x2a4]")
                && line.contains("[site+0x276]"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x0040f6d0")
                && line.contains("[site+0x2a8/+0x272/+0x27a/+0x29e]")
                && line.contains("[site+0x3d4/+0x3d5]"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00403ef3 / 0x00404489")
                && line.contains("0x0046f073 / 0x004707ff")
                && line.contains("0x0040ef10"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("[+0x00/+0x04/+0x0c]")
                && line.contains("0x0040ef1c")
                && line.contains("0x0040f5d4")
                && line.contains("[site+0x276]")
                && line.contains("[site+0x27a]"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x004707ff")
                && line.contains("0x004706b0")
                && line.contains("selector-0x13")
                && line.contains("0x004197e0 / 0x004134d0 / 0x0040eba0 / 0x0052eb90 / 0x0040ef10"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00472b40")
                && line.contains("selector-0x72")
                && line.contains("0x00472bef / 0x00472d03"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00422bb4")
                && line.contains("0x0062b2fc")
                && line.contains("literal flags 1/0")
                && line.contains("out-param"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00508fd1 / 0x005098eb")
                && line.contains("[this+0x7c]")
                && line.contains("vtable slot +0x58 plus 0x00507cf0")
                && line.contains("arg3 forced to zero"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00473c20")
                && line.contains("0x006ce808..0x006ce988")
                && line.contains("0x00473c98")
                && line.contains("queued id slot"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x0042128d")
                && line.contains("0x00422305")
                && line.contains("0x004269c9/0x00426a2a")
                && line.contains("0x004282a9 / 0x004300d6"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00413440")
                && line.contains("0x36b1 / 0x36b2 / 0x36b3")
                && line.contains("save side")
                && line.contains("slot +0x44"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00413280")
                && line.contains("slot +0x40")
                && line.contains("0x0040ce60"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x0040f047")
                && line.contains("0x0040f5d4")
                && line.contains("[site+0x27a]"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x36b1/0x36b2/0x36b3"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x0040d450"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00410b30..0x004118f4") && line.contains("0x00412560"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .evidence
            .iter()
            .any(|line| line.contains("0x00481430 -> 0x0047d8e0"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .evidence
            .iter()
            .any(|line| line.contains("0x0040c9a0"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .evidence
            .iter()
            .any(|line| line.contains("0x0040a3a1..0x0040a4d3")
                && line.contains("0x0040fcc0..0x0040fe28")
                && line.contains("0x00422c62..0x00422d3c"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .evidence
            .iter()
            .any(|line| line.contains("0x0040d4aa/0x0040d4b0")
                && line.contains("0x0041114a7/0x004111572")
                && line.contains("0x0041118aa/0x0041118f4"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .evidence
            .iter()
            .any(|line| line.contains("0x0040d450")
                && line.contains("[site+0x276]")
                && line.contains("0x00436590")
                && line.contains("[site+0x310]"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .evidence
            .iter()
            .any(|line| line.contains("0x00410b30..0x004118f4")
                && line.contains("0xbc-stride")
                && line.contains("[site+0x310/+0x338/+0x360]"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[1]
            .evidence
            .iter()
            .any(|line| line.contains("0x00412560")
                && line.contains("0x006cec78")
                && line.contains("0x0062ba8c"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[2]
            .evidence
            .iter()
            .any(|line| line.contains("0x00413280") && line.contains("0x0040ce60"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[2]
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x0040cd70 cached source/candidate resolver"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .blockers
            .iter()
            .any(|line| line.contains("0x00413440")
                && line.contains("0x36b1/0x36b2/0x36b3")
                && line.contains("load-save strip"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .blockers
            .iter()
            .any(|line| line.contains("0x00413280")
                && line.contains("0x0040ce60")
                && line.contains("stream-load bridge"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .blockers
            .iter()
            .any(|line| line.contains("0x00481210")
                && line.contains("0x004133b0")
                && line.contains("0x0040ef10"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .blockers
            .iter()
            .any(|line| line.contains("0x00431b20")
                && line.contains("0x00433130")
                && line.contains("0x0042db20")
                && line.contains("0x0042e050")
                && line.contains("0x0062be18")
                && line.contains("[event+0x7ef]")
                && line.contains("kind 8"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x00433130")
                && line.contains("0x0062be18")
                && line.contains("0x4e21/0x4e22")
                && line.contains("0x004d90ba..0x004d91ed")
                && line.contains("0x4e98..0x4ea2")
                && line.contains("0x004d91b3"))
    );
    assert!(
        trace.near_city_acquisition_projection_hypotheses[0]
            .evidence
            .iter()
            .any(|line| line.contains("0x004db02a")
                && line.contains("0x004db1b8..0x004db309")
                && line.contains("0x4e84")
                && line.contains("0x004db9e5..0x004db9f1")
                && line.contains("0x00432ea0"))
    );
    assert_eq!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .len(),
        25
    );
    assert_eq!(trace.near_city_acquisition_remaining_owner_gaps.len(), 2);
    assert_eq!(trace.near_city_acquisition_region_lane_statuses.len(), 4);
    assert!(trace.atlas_candidate_consumers.iter().any(|line| {
        line.contains("0x00420030 / 0x00420280")
            && line.contains("0x006cec20")
            && line.contains("peer-site boolean/selector pair")
    }));
    assert!(trace.atlas_candidate_consumers.iter().any(|line| {
        line.contains("0x0040dc40") && line.contains("linked-site mutation validator/apply owner")
    }));
    assert!(trace.atlas_candidate_consumers.iter().any(|line| {
        line.contains("0x00402cb0") && line.contains("direct-placement builder owner")
    }));
    assert!(trace.next_owner_questions.iter().any(|line| {
        line.contains("repopulates placed-structure owner-company field [site+0x276]")
            && line.contains("0x00431b20")
    }));
    assert!(trace.next_owner_questions.iter().any(|line| {
        line.contains("0x0040d450 / 0x00410b30..0x004118f4")
            && line.contains("0x00412560")
            && line.contains("[site+0x2b4/+0x2b8/+0x2bc]")
    }));
    assert!(
        trace
            .linked_transit_minimum_persisted_identity_inputs
            .iter()
            .any(|line| line.contains("[site+0x276]")
                && line.contains("[site+0x04]")
                && line.contains("0x0047efe0 / 0x0047fd50"))
    );
    assert!(
        trace
            .linked_transit_minimum_persisted_identity_inputs
            .iter()
            .any(|line| line.contains("[site+0x2a4]")
                && line.contains("[site+0x2a8]")
                && line.contains("[peer+0x04/+0x08]"))
    );
    assert!(
        trace
            .linked_transit_live_rebuilt_cache_lanes
            .iter()
            .any(|line| line.contains("0x004093d0")
                && line.contains("[company+0x0d3e]")
                && line.contains("+0x02/+0x06/+0x0a"))
    );
    assert!(
        trace
            .linked_transit_live_rebuilt_cache_lanes
            .iter()
            .any(|line| line.contains("0x00407bd0") && line.contains("[site+0x0e/+0x12/+0x16]"))
    );
    assert!(
        trace
            .linked_transit_live_rebuilt_cache_lanes
            .iter()
            .any(|line| line.contains("0x00481910")
                && line.contains("0x004819b0")
                && line.contains("0x004a9340"))
    );
    assert!(
        trace
            .linked_transit_live_rebuilt_cache_lanes
            .iter()
            .any(|line| line.contains("0x004aee2b")
                && line.contains("[site+0x5c5]")
                && line.contains("[world+0x15]"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00429c10")
                && line.contains("0x004093d0")
                && line.contains("live company roster"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00444690")
                && line.contains("0x004133b0")
                && line.contains("0x0040ee10")
                && line.contains("0x00480710")
                && line.contains("0x004160aa"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("[company+0x0d3e]") && line.contains("0x00409720"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("[company+0x0d3a]") && line.contains("0x00407bd0"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0062ba8c")
                && line.contains("0x0041f4e0")
                && line.contains("0x0041ede0")
                && line.contains("0x0041e970"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x004a6360")
                && line.contains("0x004a6630")
                && line.contains("0x00494fb0"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00408280") && line.contains("0x00408380"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00409770") && line.contains("0x00409830"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("[site+0x5bd]")
                && line.contains("0x00407780")
                && line.contains("0x004077e0"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("+0x00/+0x01")
                && line.contains("+0x02")
                && line.contains("+0x06")
                && line.contains("+0x0a")
                && line.contains("+0x0e/+0x12/+0x16"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("[site+0x5c1]")
                && line.contains("0x00481910")
                && line.contains("0x004a9340")
                && line.contains("0x004819b0"))
    );
    assert!(
        trace
            .linked_transit_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("[site+0x5c5]") && line.contains("0x004aee2b"))
    );
    assert!(
        trace
            .linked_transit_remaining_owner_gaps
            .iter()
            .any(|line| line.contains("0x0040e360..0x0040edf6")
                && line.contains("[site+0x276]")
                && line.contains("earlier restore or service owner"))
    );
    assert!(trace.linked_transit_remaining_owner_gaps.iter().any(
        |line| line.contains("0x006cec20")
            && line.contains("0x0041f4e0")
            && line.contains("0x00494fb0")
    ));
    assert!(
        trace
            .near_city_acquisition_region_input_fields
            .iter()
            .any(|line| line.contains("[site+0x276]"))
    );
    assert!(
        trace
            .near_city_acquisition_peer_input_fields
            .iter()
            .any(|line| line.contains("[site+0x04]"))
    );
    assert!(
        trace
            .near_city_acquisition_peer_input_fields
            .iter()
            .any(|line| line.contains("[cell+0xd4]") && line.contains("[cell+0xd6]"))
    );
    assert!(
        trace
            .near_city_acquisition_company_input_fields
            .iter()
            .any(|line| line.contains("0x2329/0x0d"))
    );
    assert!(
        trace
            .near_city_acquisition_company_input_fields
            .iter()
            .any(|line| line.contains("[company+0x0d35]") && line.contains("0x00401860"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("[company+0x0d35]")
                && line.contains("[company+0x7664/+0x7668/+0x766c]"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x004134d0")
                && line.contains("0x0040f6d0")
                && line.contains("[site+0x2a4]")
                && line.contains("[site+0x276]")
                && line.contains("[site+0x3d4/+0x3d5]"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0040ef10")
                && line.contains("0x00403ef3 / 0x00404489")
                && line.contains("0x0046f073 / 0x004707ff"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0046f073 / 0x004707ff")
                && line.contains("[+0x00/+0x04/+0x0c]")
                && line.contains("0x0040ef10")
                && line.contains("0x0040f5d4"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x004707ff")
                && line.contains("0x004706b0")
                && line.contains("selector-0x13"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00472b40")
                && line.contains("selector-0x72")
                && line.contains("0x00472bef / 0x00472d03"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00422bb4")
                && line.contains("live args")
                && line.contains("literal flags 1/0")
                && line.contains("out-param"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00508fd1 / 0x005098eb")
                && line.contains("[this+0x7c]")
                && line.contains("0x0040eba0")
                && line.contains("hard zero third arg"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00473c20")
                && line.contains("0x006ce808..0x006ce988")
                && line.contains("0x00473c98")
                && line.contains("post-create refresh path"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0042128d")
                && line.contains("0x00422305")
                && line.contains("0x004269c9/0x00426a2a")
                && line.contains("0x004282a9/0x004300d6"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00413440")
                && line.contains("0x36b1/0x36b2/0x36b3")
                && line.contains("slot +0x44"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0047efe0") && line.contains("[site+0x276]"))
    );
    let linked_transit_branch = trace.companies[0]
        .branches
        .iter()
        .find(|branch| branch.branch_name == "linked_transit_roster_maintenance")
        .expect("linked-transit branch");
    assert_eq!(
        linked_transit_branch.status,
        "blocked_missing_site_cache_input_owner_mapping"
    );
    assert!(
        linked_transit_branch
            .grounded_inputs
            .iter()
            .any(|line| line.contains("[company+0x0d3e]"))
    );
    assert!(
        linked_transit_branch
            .grounded_inputs
            .iter()
            .any(|line| line.contains("[company+0x0d3a]"))
    );
    assert!(
        linked_transit_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00409720"))
    );
    assert!(
        linked_transit_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00408f70"))
    );
    assert!(
        linked_transit_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00408280"))
    );
    assert!(
        linked_transit_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00408380"))
    );
    assert!(
        linked_transit_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00409770"))
    );
    assert!(
        linked_transit_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00409830"))
    );
    assert!(
        linked_transit_branch
            .blocking_inputs
            .iter()
            .any(|line| line.contains("0x00408280 / 0x00408380"))
    );
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x00409720")
            && line.contains("[company+0x0d3e]")
            && line.contains("[company+0x0d3a]")
            && line.contains("0x00409950")
    }));
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x00408280")
            && line.contains("[site+0x16]")
            && line.contains("0x00409770")
            && line.contains("0x00409830")
    }));
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x00481910")
            && line.contains("0x004819b0")
            && line.contains("[site+0x5c1]")
            && line.contains("0x004a9340")
            && line.contains("0x004aee2b")
            && line.contains("[site+0x5c5]")
    }));
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x00407780")
            && line.contains("0x004077e0")
            && line.contains("[site+0x5bd]")
            && line.contains("0x1a-byte")
    }));
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x004093d0")
            && line.contains("0x00407bd0")
            && line.contains("+0x02")
            && line.contains("+0x06")
            && line.contains("+0x0a")
            && line.contains("+0x0e/+0x12/+0x16")
    }));
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x0062ba8c")
            && line.contains("0x0041f4e0")
            && line.contains("0x00494fb0")
            && line.contains("remaining linked-transit gap is narrower again")
    }));
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x00409720")
            && line.contains("0x004093d0")
            && line.contains("0x00407bd0")
            && line.contains("0x00409950")
    }));
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x0040eba0")
            && line.contains("[site+0x2a4]")
            && line.contains("0x004814c0 / 0x00481480")
            && line.contains("0x0042c9f0 / 0x0042c9a0")
    }));
    assert!(trace.notes.iter().any(|line| {
        line.contains("0x0040ea96..0x0040eb65")
            && line.contains("[site+0x276]")
            && line.contains("consumes")
            && line.contains("rather than rehydrating")
    }));
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0041f7e0 / 0x0041f810 / 0x0041f850")
                && line.contains("[site+0x2a4]"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x004269b0")
                && line.contains("0x0062b26c")
                && line.contains("[site+0x2a4]"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(
                |line| line.contains("0x004131f0 -> 0x00412fb0 -> 0x004120b0 -> 0x00412ab0")
                    && line.contains("[candidate+0x32]")
            )
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0040dc40")
                && line.contains("[site+0x276]")
                && line.contains("0x0040d1f0 / 0x00480710"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line
                .contains("0x00402cb0 -> 0x00403ed5/0x0040446b -> 0x004134d0 -> 0x0040ef10"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x00431b20")
                && line.contains("0x0061039c")
                && line.contains("0x00430040 / 0x00426d60 / 0x0042fc90"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0040d450")
                && line.contains("[site+0x310]")
                && line.contains("0x00410b30..0x004118f4")
                && line.contains("0x00412560"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x0042bbf0")
                && line.contains("0x0042bbb0")
                && line.contains("0x0042c9f0")
                && line.contains("0x0042c9a0"))
    );
    assert!(
        trace
            .near_city_acquisition_runtime_backed_input_families
            .iter()
            .any(|line| line.contains("0x2329/0x0d"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_live_owner_families
            .iter()
            .any(|line| line.contains("0x0040d450") && line.contains("[site+0x310]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_live_owner_families
            .iter()
            .any(|line| line.contains("0x00410b30..0x004118f4")
                && line.contains("[site+0x310/+0x338/+0x360]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_live_owner_families
            .iter()
            .any(|line| line.contains("0x00412560"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_candidate_gate_fields
            .iter()
            .any(|line| line.contains("[+0x20/+0x22/+0x24/+0x28/+0x2c/+0x44]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_candidate_gate_fields
            .iter()
            .any(|line| line.contains("0x006cec78"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_candidate_gate_fields
            .iter()
            .any(|line| line.contains("0x0062ba8c"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_candidate_gate_fields
            .iter()
            .any(|line| line.contains("vtable slot +0x80") && line.contains("[site+0x246]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_candidate_gate_fields
            .iter()
            .any(|line| line.contains("0x0040fb8d")
                && line.contains("0x00410721")
                && line.contains("0x004126d3"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_runtime_writer_roles
            .iter()
            .any(|line| line.contains("0x0040d450") && line.contains("[site+0x310]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_runtime_writer_roles
            .iter()
            .any(|line| line.contains("0x00410b30..0x004118f4")
                && line.contains("[site+0x310/+0x338/+0x360]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_runtime_writer_roles
            .iter()
            .any(|line| line.contains("0x0041114a7/0x004111572")
                && line.contains("0x0041114b7/0x004111582"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_runtime_writer_roles
            .iter()
            .any(|line| line.contains("0x0041118aa/0x0041118f4"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_runtime_writer_roles
            .iter()
            .any(|line| line.contains("0x0040c9a0") && line.contains("[site+0x2b4/+0x2b8/+0x2bc]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_direct_caller_families
            .iter()
            .any(|line| line.contains("0x0040fb70")
                && line.contains("vtable slot +0x80")
                && line.contains("owner-present flag")
                && line.contains("0x00412560"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_direct_caller_families
            .iter()
            .any(|line| line.contains("0x004b4052 / 0x004b46ec") && line.contains("0x0062b26c"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_direct_caller_families
            .iter()
            .any(|line| line.contains("0x00401633") && line.contains("0x2329/0x0d"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_direct_caller_families
            .iter()
            .any(|line| line.contains("0x0044b81a")
                && line.contains("0x00436590")
                && line.contains("0x65"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_direct_caller_families
            .iter()
            .any(|line| line.contains("0x004b70f5 / 0x004b7979")
                && line.contains("0x004337a0")
                && line.contains("0x00540120 / 0x00518140"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_formula_input_lanes
            .iter()
            .any(|line| line.contains("[+0x20/+0x22]")
                && line.contains("[+0x24/+0x28]")
                && line.contains("[+0x44]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_formula_input_lanes
            .iter()
            .any(|line| line.contains("[world+0x0d]") && line.contains("[world+0x4afb]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_formula_input_lanes
            .iter()
            .any(|line| line.contains("0x00455810 / 0x00455800 / 0x0044ad60")
                && line.contains("[site+0x276]")
                && line.contains("0x66/0x68"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_formula_input_lanes
            .iter()
            .any(|line| line.contains("[+0x18/+0x1c/+0x2a/+0x2c/+0x44]")
                && line.contains("[site+0x78c]")
                && line.contains("[site+0x391]"))
    );
    assert!(
        trace
            .near_city_acquisition_tri_lane_formula_input_lanes
            .iter()
            .any(|line| line.contains("[world+0x4caa]")
                && line.contains("[company+0x0d5d]")
                && line.contains("[site+0x310]")
                && line.contains("[site+0x360]"))
    );
    assert!(
        trace
            .near_city_acquisition_remaining_owner_gaps
            .iter()
            .any(|line| line.contains("[site+0x276]")
                && line.contains("0x36b1/0x36b2/0x36b3")
                && line.contains("0x0047efe0")
                && line.contains("0x004134d0 / 0x0040f6d0")
                && line.contains("0x0040ef10")
                && line.contains("[+0x0c]")
                && line.contains("best-effort owner projection"))
    );
    assert!(
        !trace
            .near_city_acquisition_remaining_owner_gaps
            .iter()
            .any(|line| line.contains("[site+0x2a4]"))
    );
    assert!(
        trace
            .near_city_acquisition_remaining_owner_gaps
            .iter()
            .any(|line| line.contains("0x0040d450")
                && line.contains("0x00410b30..0x004118f4")
                && line.contains("best-effort tri-lane projection"))
    );
    assert!(
        trace
            .near_city_acquisition_region_lane_statuses
            .iter()
            .any(|line| line.contains("[site+0x276]")
                && line.contains("0x004014b0")
                && line.contains("0x36b1/0x36b2/0x36b3")
                && line.contains("0x0047efe0")
                && line.contains("0x004134d0 / 0x0040f6d0")
                && line.contains("best-effort projected owner lane"))
    );
    assert!(
        trace
            .near_city_acquisition_region_lane_statuses
            .iter()
            .any(|line| line.contains("[site+0x2a4]")
                && line.contains("record's own site id")
                && line.contains("0x00480210")
                && line.contains("0x004269b0")
                && line.contains("reconstructible from collection identity"))
    );
    assert!(
        trace
            .near_city_acquisition_region_lane_statuses
            .iter()
            .any(|line| line.contains("[site+0x310/+0x338/+0x360]")
                && line.contains("0x0040cac0")
                && line.contains("0x0040c9a0")
                && line.contains("0x0040d450")
                && line.contains("0x00410b30..0x004118f4")
                && line.contains("0x00412560"))
    );
    assert!(
        trace
            .near_city_acquisition_region_lane_statuses
            .iter()
            .any(
                |line| line.contains("0x004131f0 -> 0x00412fb0 -> 0x004120b0 -> 0x00412ab0")
                    && line.contains("0x0040ce60")
                    && line.contains("[site+0x3cc/+0x3d0]")
            )
    );
    assert!(
        trace
            .peer_site_runtime_reconstruction_steps
            .iter()
            .any(|line| {
                line.contains("[cell+0xd4]")
                    && line.contains("[cell+0xd6]")
                    && line.contains("0x0042bbf0/0x0042bbb0")
            })
    );
    assert!(trace.next_owner_questions.iter().any(|line| {
        line.contains("0x004160aa") && line.contains("0x0040ee10") && line.contains("0x0040edf6")
    }));
    let acquisition_branch = trace.companies[0]
        .branches
        .iter()
        .find(|branch| branch.branch_name == "industry_acquisition_side_branch")
        .expect("missing acquisition branch");
    assert_eq!(
        acquisition_branch.status,
        "blocked_missing_near-city_owner_mapping"
    );
    assert!(
        acquisition_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x004014b0"))
    );
    assert!(
        acquisition_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x004019e0"))
    );
    assert!(
        acquisition_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x004010f0"))
    );
    assert!(
        acquisition_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00420030 / 0x00420280"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00405920"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0041f6e0") && line.contains("0x0042b2d0"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00480710") && line.contains("route-entry-anchor"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0042bbf0")
                && line.contains("0x0042bbb0")
                && line.contains("[cell+0xd4]"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0042c9f0")
                && line.contains("0x0042c9a0")
                && line.contains("[cell+0xd6]"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x004269b0")
                && line.contains("0x0062b26c")
                && line.contains("[site+0x276]/[site+0x27a]"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00426dce..0x00426ea1")
                && line.contains("0x0062b26c")
                && line.contains("non-subtype-4"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00430040..0x004300d6") && line.contains("0x09/0x0b/0x0c"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00431b20")
                && line.contains("0x0061039c")
                && line.contains("0x00430040")
                && line.contains("0x00426d60")
                && line.contains("0x0042fc90"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0042fc90")
                && line.contains("0x0062b26c")
                && line.contains("[site+0x276]")
                && line.contains("vtable slot +0x70"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x004134d0") && line.contains("0x0040f6d0"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00403ef3 / 0x00404489"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0046f073 / 0x004707ff"))
    );
    assert!(trace.known_bridge_helpers.iter().any(|line| {
        line.contains("0x0046f073 / 0x004707ff")
            && line.contains("[+0x0c]")
            && line.contains("0x0040f5d4")
    }));
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x004706b0")
                && line.contains("selector-0x13")
                && line.contains("0x0040ef10"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00472b40")
                && line.contains("selector-0x72")
                && line.contains("0x00472bef / 0x00472d03"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00422bb4")
                && line.contains("0x0062b2fc")
                && line.contains("literal flags 1/0")
                && line.contains("out-param"))
    );
    assert!(trace.known_bridge_helpers.iter().any(|line| {
        line.contains("0x00508fd1 / 0x005098eb")
            && line.contains("[this+0x7c]")
            && line.contains("0x0040eba0")
            && line.contains("arg3 forced to zero")
    }));
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00473c20")
                && line.contains("0x006ce808..0x006ce988")
                && line.contains("0x00473c98"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0042128d")
                && line.contains("0x00421430")
                && line.contains("[site+0x276]"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00422305")
                && line.contains("event 0x7")
                && line.contains("[site+0x276]"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x004269c9 / 0x00426a2a")
                && line.contains("[site+0x276]/[site+0x27a]"))
    );
    assert!(trace.known_bridge_helpers.iter().any(|line| {
        line.contains("0x004282a9 / 0x004300d6")
            && line.contains("owner-transfer")
            && line.contains("placed-structure")
    }));
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00413440")
                && line.contains("0x36b1/0x36b2/0x36b3")
                && line.contains("slot +0x44"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040f6d0")
                && line.contains("0x00481390")
                && line.contains("0x00480210"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040df27 / 0x0040e00a / 0x0040edf6"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00444690") && line.contains("0x004133b0"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040e360..0x0040edf6")
                && line.contains("[site+0x2a8/+0x2a4/+0x276]")
                && line.contains("0x00426b10")
                && line.contains("0x00455860"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040e450") && line.contains("queued site-id"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x004160aa") && line.contains("0x0040ee10"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040dc40")
                && line.contains("[site+0x276]")
                && line.contains("0x2329/0x0d"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00417840 / 0x004197e0 / 0x004142c0 / 0x004142d0"))
    );
    assert!(trace.known_bridge_helpers.iter().any(|line| {
        line.contains("0x0040d1f0 / 0x00480710 / 0x0045b160 / 0x0045b9b0 / 0x00418be0 / 0x0040cd70")
    }));
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00402cb0 / 0x00403ed5 / 0x0040446b"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x004134d0 / 0x0040ef10"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00481430 / 0x0047d8e0"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040c9a0")
                && line.contains("[site+0x310/+0x338/+0x360]")
                && line.contains("[site+0x2b4/+0x2b8/+0x2bc]"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040d450")
                && line.contains("[site+0x310]")
                && line.contains("0x00436590"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040fb70")
                && line.contains("vtable slot +0x80")
                && line.contains("0x00412560"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00412560")
                && line.contains("0x0062ba8c")
                && line.contains("world date/flags"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00410b30..0x004118f4")
                && line.contains("[site+0x310/+0x338/+0x360]")
                && line.contains("0x00412560"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x00401633") && line.contains("0x2329/0x0d"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0044b81a")
                && line.contains("0x00436590")
                && line.contains("0x65"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x004b4052 / 0x004b46ec") && line.contains("0x0062b26c"))
    );
    assert!(trace.known_bridge_helpers.iter().any(|line| {
        line.contains("0x004b70f5 / 0x004b7979")
            && line.contains("0x004337a0")
            && line.contains("0x00540120 / 0x00518140")
    }));
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040a3a1..0x0040a4d3") && line.contains("0x0040c9a0"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x0040fcc0..0x0040fe28")
                && line.contains("0x00422c62..0x00422d3c")
                && line.contains("0x0040cac0"))
    );
    assert!(
        trace
            .known_bridge_helpers
            .iter()
            .any(|line| line.contains("0x005c8c50 +0x40")
                && line.contains("0x0040ce60")
                && line.contains("0x0040cd70 / 0x0045c150"))
    );
    let city_branch = trace.companies[0]
        .branches
        .iter()
        .find(|branch| branch.branch_name == "city_connection_announcement")
        .expect("missing city branch");
    assert!(
        city_branch
            .candidate_consumers
            .iter()
            .any(|line| line.contains("0x00406050"))
    );
}
