Trace region payload-start restore boundaries

This commit is contained in:
Jan Petykiewicz 2026-04-18 17:17:55 -07:00
commit 833ad080e9

View file

@ -1703,9 +1703,14 @@ pub struct SmpSaveRegionProfileCollectionProbe {
pub struct SmpSaveRegionRecordTripletEntryProbe {
pub record_index: usize,
pub name: String,
pub record_payload_relative_offset: usize,
pub record_payload_relative_offset_hex: String,
pub name_tag_relative_offset: usize,
pub policy_tag_relative_offset: usize,
pub profile_tag_relative_offset: usize,
pub pre_name_prefix_len: usize,
#[serde(default)]
pub pre_name_prefix_hex_bytes: Vec<String>,
pub policy_chunk_len: usize,
pub profile_chunk_len: usize,
pub policy_leading_f32_0: f32,
@ -4243,9 +4248,12 @@ fn build_region_service_trace_report(
"constructor-side evidence now proves the latches are initialized locally, so the remaining gap can legitimately be framed as post-construction restore or rebuild".to_string(),
"direct disassembly of 0x0041f590/0x0041f5b0 now proves the world-region vtable root is 0x005c9a28, so the 0x00455fc0 dispatch at slot +0x48 lands on 0x00455870 and the serializer sibling at +0x4c lands on 0x00455930".to_string(),
"direct disassembly of 0x00455870/0x00455930 now shows that callback pair only restores and serializes two triplet-like three-lane scalar bands through 0x531150/0x531030 plus 0x530720/0x52e8b0, not [region+0x276/+0x302/+0x316]".to_string(),
"direct disassembly of 0x00421510 now also shows the exact tagged loop shape: it opens 0x5209, reads 0x520a, iterates live entry ordinals through 0x518380/0x518140, seeds a stack-local world-region vtable helper through 0x0041f590/0x0041f5b0, dispatches each loaded record through slot +0x40, and only then closes 0x520b".to_string(),
"direct disassembly of 0x0041f5c0 now also shows its post-0x00455fc0 work is local to the profile collection path: it clamps [region+0x31b] back to 1.0f when needed, zeroes [region+0x317], allocates one 0x88-sized helper through 0x53b070/0x518b90, stores it at [region+0x37f], loads that helper through 0x518680, and clears [region+0x385] before returning".to_string(),
"the first caller-side checkpoint above 0x00421510 is now grounded too: 0x00444887 invokes the region collection refresh inside a broader restore sequence and then immediately advances to territory_collection_refresh_records_from_tagged_bundle 0x00487c20 and support_collection_refresh_records_from_tagged_bundle 0x0040b5d0, which makes the missing latches look like a later global rebuild seam rather than hidden work inside 0x00421510 itself".to_string(),
],
blockers: vec![
"which later restore or rebuild owner rehydrates [region+0x276/+0x302/+0x316] after the shared payload loader and triplet-band callback complete".to_string(),
"which later restore or rebuild owner rehydrates [region+0x276/+0x302/+0x316] after the 0x00421510 -> 0x0041f5c0 -> 0x00455fc0 path completes".to_string(),
"whether [region+0x25e] severity/source and any stable region id/class discriminator are serialized elsewhere in the tagged region body or recomputed immediately post-load".to_string(),
],
},
@ -4377,6 +4385,24 @@ fn build_region_service_trace_report(
.to_string(),
);
}
let pre_name_prefix_count = probe
.entries
.iter()
.filter(|entry| entry.pre_name_prefix_len != 0)
.count();
let unique_pre_name_prefix_lens = probe
.entries
.iter()
.map(|entry| entry.pre_name_prefix_len)
.collect::<BTreeSet<_>>()
.into_iter()
.collect::<Vec<_>>();
notes.push(format!(
"Grounded live-entry payload starts now also show {} of {} region records with nonzero bytes before the first 0x55f1 tag; unique pre-name prefix lengths are {:?}.",
pre_name_prefix_count,
probe.entries.len(),
unique_pre_name_prefix_lens
));
}
SmpRegionServiceTraceReport {
profile_family: analysis.profile_family.clone(),
@ -12718,8 +12744,39 @@ fn parse_save_region_record_triplet_probe(
{
return None;
}
let region_payload_start_offsets = bytes
.get(header_probe.metadata_tag_offset + 4..header_probe.records_tag_offset)
.and_then(|metadata_payload| {
let directory_root_byte_offset =
SAVE_REGION_COLLECTION_DIRECTORY_ROOT_DWORD_INDEX.checked_mul(4)?;
let directory_len_dwords =
record_count.checked_mul(SAVE_REGION_COLLECTION_DIRECTORY_ENTRY_DWORD_COUNT)?;
let directory_len_bytes = directory_len_dwords.checked_mul(4)?;
let directory_bytes = metadata_payload.get(
directory_root_byte_offset
..directory_root_byte_offset.checked_add(directory_len_bytes)?,
)?;
let records_payload_absolute_offset = header_probe.records_tag_offset.checked_add(4)?;
(0..record_count)
.map(|index| {
let entry_offset = index
.checked_mul(SAVE_REGION_COLLECTION_DIRECTORY_ENTRY_DWORD_COUNT * 4)?;
let payload_relative_offset =
read_u32_at(directory_bytes, entry_offset)? as usize;
let payload_absolute_offset = header_probe
.metadata_tag_offset
.checked_add(4)?
.checked_add(payload_relative_offset)?;
let payload_start =
payload_absolute_offset.checked_sub(records_payload_absolute_offset)?;
(payload_start <= records_payload.len()).then_some(payload_start)
})
.collect::<Option<Vec<_>>>()
})
.unwrap_or_else(|| name_offsets.clone());
let mut entries = Vec::with_capacity(record_count);
for index in 0..record_count {
let record_payload_relative_offset = region_payload_start_offsets[index];
let name_tag_relative_offset = name_offsets[index];
let policy_tag_relative_offset = policy_offsets[index];
let profile_tag_relative_offset = profile_offsets[index];
@ -12727,12 +12784,17 @@ fn parse_save_region_record_triplet_probe(
.get(index + 1)
.copied()
.unwrap_or(records_payload.len());
if record_payload_relative_offset > name_tag_relative_offset {
return None;
}
if !(name_tag_relative_offset < policy_tag_relative_offset
&& policy_tag_relative_offset < profile_tag_relative_offset
&& profile_tag_relative_offset < next_record_relative_offset)
{
return None;
}
let pre_name_prefix =
records_payload.get(record_payload_relative_offset..name_tag_relative_offset)?;
let name_payload =
records_payload.get(name_tag_relative_offset + 4..policy_tag_relative_offset)?;
let name = parse_save_len_prefixed_ascii_name(name_payload)?;
@ -12759,9 +12821,16 @@ fn parse_save_region_record_triplet_probe(
entries.push(SmpSaveRegionRecordTripletEntryProbe {
record_index: index,
name,
record_payload_relative_offset,
record_payload_relative_offset_hex: format!("0x{record_payload_relative_offset:x}"),
name_tag_relative_offset,
policy_tag_relative_offset,
profile_tag_relative_offset,
pre_name_prefix_len: pre_name_prefix.len(),
pre_name_prefix_hex_bytes: pre_name_prefix
.iter()
.map(|byte| format!("0x{byte:02x}"))
.collect(),
policy_chunk_len,
profile_chunk_len,
policy_leading_f32_0,
@ -12782,6 +12851,16 @@ fn parse_save_region_record_triplet_probe(
.is_some_and(|collection| collection.trailing_padding_len == 0)
})
.count();
let records_with_nonzero_pre_name_prefix = entries
.iter()
.filter(|entry| entry.pre_name_prefix_len != 0)
.count();
let unique_pre_name_prefix_lens = entries
.iter()
.map(|entry| entry.pre_name_prefix_len)
.collect::<BTreeSet<_>>()
.into_iter()
.collect::<Vec<_>>();
Some(SmpSaveRegionRecordTripletProbe {
profile_family: header_probe.profile_family.clone(),
source_kind: "save-region-record-triplets".to_string(),
@ -12798,6 +12877,12 @@ fn parse_save_region_record_triplet_probe(
),
"each fixed 0x55f2 policy chunk currently decodes as three leading f32 lanes, three reserved dwords, and one trailing u16 word".to_string(),
"the trailing 0x55f3 payload also carries an embedded direct profile collection with fixed 0x22-byte rows on grounded saves".to_string(),
format!(
"live-entry directory now also grounds the actual 0x520a payload starts: {} of {} records currently have nonzero bytes before the first 0x55f1 tag, with unique pre-name prefix lengths {:?}",
records_with_nonzero_pre_name_prefix,
record_count,
unique_pre_name_prefix_lens
),
format!(
"on grounded saves the 0x55f3 payload is fully consumed by that embedded profile collection: all {} decoded records currently have zero trailing padding beyond the direct profile rows",
zero_trailing_padding_record_count
@ -22841,9 +22926,13 @@ mod tests {
SmpSaveRegionRecordTripletEntryProbe {
record_index: 0,
name: "Marker09".to_string(),
record_payload_relative_offset: 0,
record_payload_relative_offset_hex: "0x0".to_string(),
name_tag_relative_offset: 0,
policy_tag_relative_offset: 0x10,
profile_tag_relative_offset: 0x2e,
pre_name_prefix_len: 0,
pre_name_prefix_hex_bytes: Vec::new(),
policy_chunk_len: 0x1a,
profile_chunk_len: 0x40,
policy_leading_f32_0: 368.0,
@ -22878,9 +22967,13 @@ mod tests {
SmpSaveRegionRecordTripletEntryProbe {
record_index: 1,
name: "Marker10".to_string(),
record_payload_relative_offset: 0x6e,
record_payload_relative_offset_hex: "0x6e".to_string(),
name_tag_relative_offset: 0x6e,
policy_tag_relative_offset: 0x7e,
profile_tag_relative_offset: 0x9c,
pre_name_prefix_len: 0,
pre_name_prefix_hex_bytes: Vec::new(),
policy_chunk_len: 0x1a,
profile_chunk_len: 0x20,
policy_leading_f32_0: 552.0,
@ -25406,9 +25499,13 @@ mod tests {
entries: vec![SmpSaveRegionRecordTripletEntryProbe {
record_index: 0,
name: "Marker09".to_string(),
record_payload_relative_offset: 0,
record_payload_relative_offset_hex: "0x0".to_string(),
name_tag_relative_offset: 0,
policy_tag_relative_offset: 0,
profile_tag_relative_offset: 0,
pre_name_prefix_len: 0,
pre_name_prefix_hex_bytes: Vec::new(),
policy_chunk_len: 0,
profile_chunk_len: 0,
policy_leading_f32_0: 368.0,
@ -25446,6 +25543,30 @@ mod tests {
trace.candidate_consumer_hypotheses[1].status,
"parallel_static_mapping_target"
);
assert!(
trace.candidate_consumer_hypotheses[1]
.evidence
.iter()
.any(|line| line.contains("0x5209")
&& line.contains("0x520a")
&& line.contains("0x520b"))
);
assert!(
trace.candidate_consumer_hypotheses[1]
.evidence
.iter()
.any(|line| line.contains("0x0041f5c0")
&& line.contains("[region+0x37f]")
&& line.contains("[region+0x385]"))
);
assert!(
trace.candidate_consumer_hypotheses[1]
.evidence
.iter()
.any(|line| line.contains("0x00444887")
&& line.contains("0x00487c20")
&& line.contains("0x0040b5d0"))
);
assert_eq!(trace.entries.len(), 1);
assert_eq!(
trace.entries[0].branches[0].status,
@ -25455,6 +25576,12 @@ mod tests {
trace.entries[0].branches[1].status,
"blocked_missing_completion_and_one_shot_latches"
);
assert!(
trace
.notes
.iter()
.any(|line| { line.contains("pre-name prefix lengths") && line.contains("[0]") })
);
}
#[test]