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

@@ -136,7 +136,7 @@ Reason:
## Next implementation node
Recommended next business node: **R2 contact/group search quality hardening**.
Recommended next business node after R12: continue R13/R14 business smoke and release-candidate closure unless new real evidence changes priority.
Reason:
@@ -149,3 +149,28 @@ Future receive-specific node after R2/R3:
- Add a local-only reconciliation helper that compares PacketReader and MsgLib messages by sanitized keys and outputs only match counts, source refs, and mismatch categories.
- Do not implement pagination until reconciliation proves which source should drive ordering.
- Do not implement file download until R3 proves message-to-cache/download mapping.
## R12 implementation result
R12 added a local-only reconciliation helper:
- `internal/isphere/message_reconciliation.go`
- `internal/isphere/message_reconciliation_test.go`
- `scripts/verify-receive-source-reconciliation.ps1`
Fixture verification:
```json
{"ok":true,"verification":"receive_source_reconciliation","use_fixture":true,"strong_matches":1,"medium_matches":1,"unmatched_left":1,"unmatched_right":1,"auto_merge_recommended":false,"exact_fixture_auto_merge_recommended":true,"raw_message_bodies_returned":false,"raw_rows_returned":false,"file_paths_returned":false,"default_receive_routing_changed":false}
```
The helper is pure comparison logic: it performs no DB reads, log reads, send, download, hook, injection, or writes.
Current match behavior:
- strong match: exact non-empty `message_id` on both sides;
- medium match: same `conversation_id`, same `sender_id`, and timestamp within 3000 ms;
- auto merge is recommended only for complete strong-match coverage with no unmatched or medium-only records.
Decision remains unchanged: default `isphere_receive_messages` routing stays PacketReader/log-backed. `msglib_readonly` remains explicit only.