feat: add receive message reconciliation helper

This commit is contained in:
zhaoyilun
2026-07-11 00:38:06 +08:00
parent 57db83d36c
commit d94d0a318a
6 changed files with 252 additions and 8 deletions

View File

@@ -857,19 +857,19 @@ git push gitea main
- Produces: `func ReconcileMessageSources(left, right []MessageReconciliationCandidate) MessageReconciliationSummary`.
- Summary fields: `strong_matches`, `medium_matches`, `unmatched_left`, `unmatched_right`, `auto_merge_recommended`.
- [ ] **Step 1: Write reconciliation tests**
- [x] **Step 1: Write reconciliation tests**
Add `TestReconcileMessageSourcesStrongAndMediumMatches`: same message id is strong; same conversation/sender and timestamp within 3000ms is medium; auto merge remains false until a strong-ratio threshold is met.
- [ ] **Step 2: Implement pure Go helper**
- [x] **Step 2: Implement pure Go helper**
No DB/log IO in the helper. It only compares sanitized candidates.
- [ ] **Step 3: Add script wrapper**
- [x] **Step 3: Add script wrapper**
Script runs against fixture JSON first; optional real evidence mode prints counts and booleans only.
- [ ] **Step 4: Verify and commit**
- [x] **Step 4: Verify and commit**
```powershell
git diff --check
@@ -885,6 +885,14 @@ git push gitea main
**Acceptance gate:** 对账能力存在,但默认 receive routing 不改变。
**R12 Result:**
- Added pure Go reconciliation helper and tests.
- Added `scripts/verify-receive-source-reconciliation.ps1 -UseFixture`.
- Fixture output is sanitized and keeps `default_receive_routing_changed=false`.
- Default receive routing remains PacketReader/log-backed; no `auto` merge was enabled.
---
### R13: End-to-end business goals smoke