feat: add msglib display entity extraction

This commit is contained in:
zhaoyilun
2026-07-10 03:02:16 +08:00
parent 974fcaa018
commit 8be4a6a6c5
8 changed files with 459 additions and 26 deletions

View File

@@ -110,12 +110,48 @@ Initial display sources:
- `received_file_metadata` from `TD_ReceiveFileRecord`.
- `sent_file_metadata` from `TD_SendFileRecord`.
### `display_entities`
Same safe provider/DB validation as `display_sources`, but returns bounded normalized contact/group display metadata.
Required args:
- `sqlite_dll_path`
- `db_path`
- `entity_type`: `contacts` or `groups`
Optional args:
- `password`: default `123`.
- `query`: optional string matched against allowlisted jid/name columns.
- `limit`: bounded to `1..100`; default `25`.
Returned data adds:
- `metadata_only=true`
- `read_only=true`
- `message_body_values_returned=false`
- `raw_rows_returned=false`
- `entities[]` entries with:
- `entity_type`
- `source_table`
- `jid`
- `display_name`
- `confidence`
- `matched_columns`
Initial allowlisted identity sources:
- Contacts: `TD_Roster(JId,Nick)`, `TD_CustomEffigy(PersonJid,PersonName)`, `tblRecent(PersonId,PersonName)`, `tblChatLevel(PersonId,PersonName)`, selected `tblPersonMsg` id/name pairs only.
- Groups: `TD_WorkGroupAuth(GroupJID,GroupName)`, `TD_WorkGroupAuth(ChildGroupJid,GroupName)`, selected `tblMsgGroupPersonMsg` group/session id/name pairs only.
## Security and scope rules
- The sidecar must open DB files with read-only connection settings.
- `db_path` must point to a file named `MsgLib.db`.
- The first contract returns schema, columns, counts, and display-source availability only.
- It does not return message bodies, contact row values, file paths, or raw row sets.
- The schema/display-source operations return schema, columns, counts, and display-source availability only.
- `display_entities` may return bounded contact/group `jid` and `display_name` metadata only.
- It does not return message bodies, message text, file paths, attachment contents, or raw row sets.
- It does not implement send, file download, mark-read, login, hooks, injection, or DB writes.
- The Go MCP layer remains the coordinator; this process is a bounded local reader.
@@ -142,6 +178,13 @@ Committed C28 implementation:
- Unit tests use a fake sidecar process; normal tests do not require real `System.Data.SQLite.dll` or copied `MsgLib.db`.
- C28 does not register a new MCP tool and does not return message bodies, file paths, raw rows, contact row values, or group row values.
Committed C29 implementation:
- Sidecar op: `display_entities`.
- Go wrapper: `DisplayEntities(ctx, DisplayEntitiesOptions)`.
- Verification script calls `display_entities` only when copied DB env paths are supplied, and prints only sanitized `entity_count` plus `source_tables` summaries.
- Evidence-backed C29 verification against the copied DB returned contact/group entity counts and source-table names without printing entity values.
## Verification
Default verification builds and checks `self_check` only:
@@ -150,7 +193,7 @@ Default verification builds and checks `self_check` only:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\verify-msglib-sidecar.ps1
```
Evidence-backed provider verification is opt-in through environment variables and should use copied DB files only:
Evidence-backed provider verification is opt-in through environment variables and should use copied DB files only. The script also verifies `display_sources` and sanitized `display_entities` summaries when these variables are present:
```powershell
$env:ISPHERE_MSGLIB_SQLITE_DLL = "<path-to-System.Data.SQLite.dll>"