fix(shipping-notice): 订单附件选择取消数量截断改为全量入选,修复超预算静默丢弃

修复:
- 合格业务附件全量入选批次 1,有多少单解析多少单,不设数量截断;
  唯一生效的选择预算为 MAX_TOTAL_BYTES=30MB,累计超限转 Review
- 数量类预算字段(MAX_INITIAL_ATTACHMENTS / EXPANSION_BATCH_SIZE /
  MAX_TOTAL_ATTACHMENTS)仅写入快照作审计记录,不再参与选择
- 扩批同步按明细重算 pending 计数,防止投影层误报「预算停扩」
- 总量兜底:EML 每封 ≤20 附件、单次 ≤50 Intake、原始输入超 30MB 拒发
This commit is contained in:
hugo committed 2026-09-22 11:02:54 +08:00
1 parent 881863478e
commit 13c33d063c
6 files changed
+78 -26

No files matched your search

@@ -166,6 +166,43 @@ def test_attachment_selection_snapshot_stops_at_total_byte_budget():
assert by_name['second.pdf']['skip_reason_codes'] == ['budget_total_bytes']
def test_attachment_selection_snapshot_selects_all_eligible_attachments():
"""合格业务附件全量入选批次 1:数量类预算字段不得截断,有多少单解析多少单。"""
attachments = [
{
'attachment_key': f'po-{no:02d}.pdf',
'filename': f'PO_45188381{no:02d}.pdf',
'mime_type': 'application/pdf',
'size': 48000,
'content_hash': f'{no:02d}' * 32,
'ready_for_extraction': True,
'catalog_reason': 'ready_for_extraction',
}
for no in range(1, 13)
]
snapshot = build_attachment_selection_snapshot(
intakes=[_preview_intake('SNI-ALL', attachments)],
max_total_attachments=6,
expansion_batch_size=2,
)
assert snapshot['selection_version'] == 'shipping_notice_attachment_selection.v1'
# 关键断言:即使数量预算字段为 6,12 份同分 PDF 也必须全部入选批次 1,
# 不产生 planned_selection_batch 或任何跳过原因码(本用例复现历史丢件形态)。
assert snapshot['eligible_attachment_count'] == 12
assert snapshot['selected_attachment_count'] == 12
assert snapshot['planned_attachment_count'] == 12
assert snapshot['pending_expansion_attachment_count'] == 0
assert snapshot['pending_expansion_batches'] == {}
assert [item['filename'] for item in snapshot['items'] if item['selected']] == [
f'PO_45188381{no:02d}.pdf' for no in range(1, 13)
]
for item in snapshot['items']:
assert item['selection_batch'] == 1
assert item['planned_selection_batch'] is None
assert item['skip_reason_codes'] == []
def test_attachment_selection_snapshot_excludes_inline_resources_from_counts():
"""邮件签名图不属于用户业务附件,不能占用识别计划的附件数量或预算。"""
snapshot = build_attachment_selection_snapshot(intakes=[
@@ -234,6 +271,7 @@ def test_serialize_order_extraction_run_includes_selection_plan_summary(monkeypa
run_no='SNER-SELECTION',
owner_agent_id=1,
conversation_id='conv-selection',
client_submission_id=None,
status='queued',
phase='queued',
schema_version_id=1,