Header edits are determined by the add_forwarding_header_edits_common and add_forwarding_header_edits_per_recip functions. If notify_method is non-empty, so that forwarding the message is check_mail's responsibility, then it can apply the correct per-recip header edits independently for each recipient. If notify_method is empty so that forwarding is the MTA's responsibility, then only a single set of header edits can be applied. In this case the edits for the first passed recipient will be used (the common headers alone are insufficient as spam and virus tagging is only done in per-recip headers).
The header edits are recorded in an Amavis::Out::EditHeader object, which is found in the $msginfo->header_edits property. This object does not provide methods to access its properties, so you will have to treat it as a hash reference and access keys directly. The prepend and append keys each contain an array of headers to be added, before or after existing headers respectively. Each element of these arrays is simply a string containing the entire header line. Both arrays contain the set of additional headers in the order in which they should appear in the message.
The edit key contains a hash of headers to be edited. The hash keys are the names of the header fields. If a value is undef, then that header should simply be deleted. Otherwise the value will be a code reference, which takes two arguments: the header name and the original value. It returns the new value for the header. If you need to obtain the original header value to pass to a header edit function, this can be obtained from $msginfo->mime_entity->head->get(.header_name, 0)