feat: enrich search with msglib display entities

This commit is contained in:
zhaoyilun
2026-07-10 03:09:37 +08:00
parent 8be4a6a6c5
commit 1277316663
11 changed files with 400 additions and 30 deletions

View File

@@ -2302,7 +2302,8 @@ Bounded display entity extraction result:
**Goal:** Wire the C29 bounded `DisplayEntities` source into `isphere_search_contacts` and `isphere_search_groups` as an optional env-configured enrichment path, while preserving the current log-backed fallback and keeping message bodies, file paths, downloads, sends, writes, hooks, injection, DB mutation, and raw row dumps out of scope.
**Planned files:**
**Files:**
- Create: `internal/tools/display_entities.go`
- Modify: `internal/tools/isphere_contacts.go`
- Modify: `internal/tools/isphere_contacts_test.go`
- Modify: `internal/tools/isphere_groups.go`
@@ -2318,24 +2319,24 @@ Bounded display entity extraction result:
- Add an injectable display-entity source interface around `internal/msglib.Client`.
- Keep default MCP behavior unchanged when `ISPHERE_MSGLIB_SIDECAR_EXE`, `ISPHERE_MSGLIB_SQLITE_DLL`, or `ISPHERE_MSGLIB_DB` are absent.
- When all env vars are present, enrich contact/group search results from `DisplayEntities` with bounded `query` and `limit`.
- Normal tests use fake display-entity source data; verification script should include a synthetic/fake enrichment smoke before any real copied DB smoke.
- Normal tests use fake display-entity source data; `scripts/verify-go-mcp.ps1` clears MsgLib env by default to keep standard smoke deterministic.
- Do not expose a new MCP tool in this loop.
- [ ] **Step 1: Write failing contact/group enrichment tests**
- [x] **Step 1: Write failing contact/group enrichment tests**
Add tests proving contacts/groups can consume injected display entities and still pass existing log-backed/default behavior.
Added fake-source tests proving `isphere_search_contacts` and `isphere_search_groups` can consume injected MsgLib display entities, pass query/limit/entity type, and return `msglib_readonly` metadata. Verified RED with missing `RegisterISphereContactToolsWithDisplayEntities` and `RegisterISphereGroupToolsWithDisplayEntities`.
- [ ] **Step 2: Implement optional display-entity source wiring**
- [x] **Step 2: Implement optional display-entity source wiring**
Implement source interface and env-configured `internal/msglib` client construction without changing default empty-source behavior.
Added `DisplayEntitySource`, mapping/merge helpers, contact/group registration functions with optional display entity source, and `NewServerFromEnv` MsgLib env wiring. Partial MsgLib env config now fails fast; default nil source remains unchanged.
- [ ] **Step 3: Update verification/docs**
- [x] **Step 3: Update verification/docs**
Extend `scripts/verify-go-mcp.ps1` with synthetic/fake enrichment smoke and update status/matrix/plan.
Updated `scripts/verify-go-mcp.ps1` to clear MsgLib env for deterministic default verification and added `msglib_configured=false` to the verification result. Updated status/matrix/plan.
- [ ] **Step 4: Full verification and commit**
- [x] **Step 4: Full verification and commit**
Run:
Run before commit:
```powershell
git diff --check
@@ -2346,6 +2347,48 @@ powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-msglib-sideca
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, evidence-backed sidecar smoke with sanitized `display_entity_summaries`, and `scripts/verify-go-mcp.ps1` with `msglib_configured=false`.
---
## Loop C30 Result
Optional MsgLib MCP enrichment result:
- `isphere_search_contacts` can now use injected/Env MsgLib display entities and return `msglib_readonly` contact metadata.
- `isphere_search_groups` can now use injected/Env MsgLib display entities and return `msglib_readonly` group metadata.
- Default behavior stays log/JID-backed when MsgLib env is absent.
- Standard `verify-go-mcp.ps1` stays deterministic by clearing MsgLib env; real copied-DB MCP smoke is deferred to C31 so it can be sanitized separately.
---
## Loop C31: Optional real MsgLib MCP enrichment smoke
**Goal:** Add an optional verification path that proves `isphere_search_contacts` and `isphere_search_groups` can call the real copied-DB MsgLib sidecar through MCP, while printing only sanitized counts/source metadata by default.
**Planned files:**
- Modify: `scripts/verify-go-mcp.ps1` or add a focused optional verification script.
- 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 verification remains deterministic and does not use real MsgLib env.
- Optional verification is gated by explicit env variables and copied DB paths.
- Output only counts, source names, and booleans; do not print display names, JIDs, message bodies, file paths, or raw rows.
- [ ] **Step 1: Add optional real-MsgLib MCP smoke**
Implement opt-in smoke with sanitized summary only.
- [ ] **Step 2: Run default and optional verification**
Run default full verification and optional copied-DB smoke if paths are available.
- [ ] **Step 3: Update docs and commit**
Record sanitized evidence and next loop.
---
## Self-Review