feat: wire explicit msglib receive source

This commit is contained in:
zhaoyilun
2026-07-10 09:11:22 +08:00
parent 3f270b454f
commit 5a1b85906b
8 changed files with 250 additions and 25 deletions

View File

@@ -2804,17 +2804,57 @@ Explicit MsgLib receive source selection result:
- Standard `scripts/verify-go-mcp.ps1` remains deterministic and should still report `msglib_configured=false`.
- Optional copied-DB smoke must print only counts/source refs/booleans and must not print message body values, file paths, raw rows, entity values, sends, downloads, hooks, injection, or DB writes.
- [ ] **Step 1: Write server wiring RED test**
- [x] **Step 1: Write server wiring RED test**
Use injected/fake sources or env-shaped construction to prove the server can register both primary and MsgLib receive sources while default calls stay on primary.
Added `TestNewServerFromEnvWiresExplicitMsgLibReceiveSource` with a fake MsgLib client factory. RED failed because `newMsgLibClient`/`msgLibClient` did not exist.
- [ ] **Step 2: Implement env wiring**
- [x] **Step 2: Implement env wiring**
Reuse `msglib.ConfigFromEnv`/client construction and pass `isphere.MsgLibMessageSource` into the C40 selector. Keep partial-env failure behavior.
Added `msgLibSourcesFromEnv`, a replaceable `newMsgLibClient` factory, and `NewServerWithSourcesAndMsgLibReceive`. Full MsgLib env now creates one sidecar client used for both display enrichment and explicit MsgLib receive source.
- [ ] **Step 3: Add optional sanitized smoke and docs**
- [x] **Step 3: Add optional sanitized smoke and docs**
Extend optional verification to call explicit `msglib_readonly` only when copied DB env is present, printing sanitized result only.
Extended `scripts/verify-msglib-mcp-enrichment.ps1` to call `isphere_receive_messages` with `source_preference="msglib_readonly"`. Output includes only DB receive count/source refs and booleans; message body values are not printed.
---
## Loop C41 Result
MsgLib receive env wiring result:
- `NewServerFromEnv` now wires env-configured MsgLib into both optional display enrichment and explicit DB receive source.
- Default `auto` remains PacketReader/log-backed; standard `verify-go-mcp.ps1` still clears MsgLib env and reports `msglib_configured=false`.
- Explicit `source_preference="msglib_readonly"` reaches `internal/isphere.MsgLibMessageSource`.
- Optional copied-DB MCP smoke now proves explicit DB receive with sanitized output: count, `msglib:<source_table>` refs, and booleans only.
---
## Loop C42: MsgLib receive operator hardening and reconciliation precheck
**Goal:** Harden the operator-facing explicit DB receive path and prepare reconciliation between PacketReader and MsgLib rows without changing default routing.
**Planned files:**
- Likely modify docs/runbook/verification only unless a test exposes a behavior gap.
- Optionally add a focused reconciliation precheck doc under `docs/source-discovery/`.
- Modify status/matrix/plan after implementation.
**Planned behavior:**
- Keep default `auto` unchanged.
- Make operator instructions clear: when to use PacketReader, when to use `msglib_readonly`, and what evidence is safe to print.
- Identify the next reconciliation key candidates: message id, timestamp, sender/receiver/group ids, subject/body presence, and attachment refs.
- Do not merge sources automatically and do not add sends/downloads.
- [ ] **Step 1: Audit explicit DB receive operator UX**
Review current tool args, runbook, and optional smoke output for confusing or unsafe wording.
- [ ] **Step 2: Write reconciliation precheck note**
Document what can and cannot be compared between PacketReader and MsgLib rows using only sanitized evidence.
- [ ] **Step 3: Verify docs and decide next implementation node**
Run full verification and choose whether C43 should add a reconciliation helper, pagination, or attachment/file mapping precheck.
---
## Self-Review