feat: enrich receive messages with display names

This commit is contained in:
zhaoyilun
2026-07-10 08:01:15 +08:00
parent 10e7a616c6
commit 298482c25d
6 changed files with 232 additions and 21 deletions

View File

@@ -2419,29 +2419,80 @@ Optional real MsgLib MCP enrichment smoke result:
**Goal:** Reuse the optional MsgLib display-entity source to enrich `isphere_receive_messages` sender/conversation display fields, without changing message text/body handling or adding send/download/write behavior.
**Planned files:**
**Files:**
- Modify: `internal/tools/isphere_read.go`
- Modify: `internal/tools/isphere_read_test.go`
- Modify: `internal/mcpserver/server.go`
- Modify: `scripts/verify-go-mcp.ps1` or optional enrichment smoke as needed
- Modify: docs/status/matrix/plan
- Modify: `docs/current-status-card.md`
- Modify: `docs/source-discovery/capability-source-matrix.md`
- Modify: `docs/superpowers/plans/2026-07-09-stage-c-log-backed-receive-messages-loop.md`
**Planned behavior:**
- Default behavior remains unchanged without MsgLib env.
- With injected display metadata, fill safe display fields such as `sender_name` and `conversation.display_name` when a matching contact/group entity exists.
- Do not alter `text`, `content_text`, attachments, raw refs, file paths, or message bodies.
- [ ] **Step 1: Write failing receive-message display-name tests**
- [x] **Step 1: Write failing receive-message display-name tests**
Use fake display metadata to prove sender/conversation display enrichment while preserving existing message fields.
Added `TestISphereReceiveMessagesToolUsesInjectedDisplayEntities`. Verified RED with missing `RegisterISphereReadToolsWithDisplayEntities`.
- [ ] **Step 2: Implement optional display-name enrichment**
- [x] **Step 2: Implement optional display-name enrichment**
Wire display metadata into receive message map output only.
Added read-tool display entity injection. The receive-message map now optionally fills `sender_name` from contact metadata and `conversation.display_name` from group/contact metadata. Message text/content/attachment/raw fields are unchanged.
- [ ] **Step 3: Verify/docs/commit**
- [x] **Step 3: Verify/docs/commit**
Run the standard full gate and update status.
Run before commit:
```powershell
git diff --check
go test ./...
go build ./cmd/isphere-mcp
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\build-msglib-sidecar.ps1
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-msglib-sidecar.ps1
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-go-mcp.ps1
```
Final verification passed: `git diff --check`, `go test ./...`, explicit `go build ./cmd/isphere-mcp`, default sidecar smoke, and deterministic `scripts/verify-go-mcp.ps1` with MsgLib env cleared.
---
## Loop C32 Result
Receive-message display-name enrichment result:
- `isphere_receive_messages` can use injected/Env MsgLib display metadata.
- `sender_name` can be populated from contact display entities.
- `conversation.display_name` can be populated from group/contact display entities.
- Default behavior remains unchanged when MsgLib env is absent.
- Message `text`, `content_text`, attachment metadata, source, and raw refs remain unchanged.
---
## Loop C33: Optional real receive-message display smoke
**Goal:** Prove receive-message display-name enrichment through the real copied-DB MsgLib sidecar using an optional smoke that prints only sanitized booleans/counts by default.
**Planned files:**
- Modify: `scripts/verify-msglib-mcp-enrichment.ps1` or add a focused optional smoke.
- Modify: docs/status/matrix/plan.
**Planned behavior:**
- Default verification remains deterministic and does not use real MsgLib env.
- Optional smoke may internally use real enriched IDs but should print only booleans/counts/source refs.
- Do not print entity values, message bodies, file paths, or raw rows.
- [ ] **Step 1: Add optional receive display smoke**
Use real MsgLib-enriched contact/group metadata internally to construct a synthetic encrypted PacketReader fixture and assert display fields are populated.
- [ ] **Step 2: Run full and optional verification**
Run standard gate plus optional smoke with copied DB env.
- [ ] **Step 3: Update docs and commit**
Record sanitized evidence and next loop.
---