feat: add msglib sidecar go client
This commit is contained in:
@@ -2174,10 +2174,11 @@ Bounded MsgLib sidecar result:
|
||||
|
||||
**Goal:** Add a Go-side client wrapper that can call the C27 x86 sidecar through a bounded JSON process contract, without exposing a new MCP tool or reading message bodies yet.
|
||||
|
||||
**Planned files:**
|
||||
**Files:**
|
||||
- Create: `internal/msglib/sidecar_client.go`
|
||||
- Create: `internal/msglib/sidecar_client_test.go`
|
||||
- Optionally update `docs/msglib-read-sidecar-contract.md`
|
||||
- Modify: `docs/msglib-read-sidecar-contract.md`
|
||||
- Modify: `docs/source-discovery/capability-source-matrix.md`
|
||||
- Modify: `docs/current-status-card.md`
|
||||
- Modify: `docs/superpowers/plans/2026-07-09-stage-c-log-backed-receive-messages-loop.md`
|
||||
|
||||
@@ -2191,25 +2192,89 @@ Bounded MsgLib sidecar result:
|
||||
- Expose only Go functions for `SelfCheck` and `DisplaySources` metadata.
|
||||
- Do not add message-body reads, file downloads, sends, writes, hooks, injection, DB mutation, or a public MCP tool in this loop.
|
||||
|
||||
- [ ] **Step 1: Write failing fake-sidecar client tests**
|
||||
- [x] **Step 1: Write failing fake-sidecar client tests**
|
||||
|
||||
Test request envelope, timeout/error handling, and display-source metadata decoding against a fake process.
|
||||
Created `internal/msglib/sidecar_client_test.go` with fake process tests for request envelope, `self_check`, `display_sources`, structured sidecar errors, timeout handling, and env config. Verified RED with undefined `Config`, `Client`, `Protocol`, and `SidecarError` symbols.
|
||||
|
||||
- [ ] **Step 2: Implement sidecar client**
|
||||
- [x] **Step 2: Implement sidecar client**
|
||||
|
||||
Use `context.Context`, `exec.CommandContext`, stdin JSON, stdout JSON, stderr capture, and small typed structs.
|
||||
Created `internal/msglib/sidecar_client.go` with protocol constants, `ConfigFromEnv`, `NewClient`, `SelfCheck`, `DisplaySources`, request ids, `exec.CommandContext`, stdin/stdout JSON, timeout, stderr capture, response validation, and typed `SidecarError` handling.
|
||||
|
||||
- [ ] **Step 3: Verify and update docs**
|
||||
- [x] **Step 3: Verify and update docs**
|
||||
|
||||
Run Go tests and update status/plan. Keep real evidence-backed sidecar smoke optional through `scripts/verify-msglib-sidecar.ps1`.
|
||||
Ran package tests for `internal/msglib` and updated the sidecar contract, capability matrix, current status card, and this plan. Real evidence-backed sidecar smoke remains covered by `scripts\verify-msglib-sidecar.ps1` rather than normal Go unit tests.
|
||||
|
||||
- [ ] **Step 4: Full verification and commit**
|
||||
- [x] **Step 4: Full verification and commit**
|
||||
|
||||
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-msglib-sidecar.ps1 # with copied DB env paths
|
||||
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, and `scripts\verify-go-mcp.ps1`.
|
||||
|
||||
---
|
||||
|
||||
## Loop C28 Result
|
||||
|
||||
Go sidecar client result:
|
||||
|
||||
- Added `internal/msglib` as the internal Go process client for `isphere.msglib.v1`.
|
||||
- Added fake-sidecar unit coverage for envelope validation, `SelfCheck`, `DisplaySources`, structured `SidecarError`, timeout behavior, and env config.
|
||||
- `ConfigFromEnv` reads `ISPHERE_MSGLIB_SIDECAR_EXE`, `ISPHERE_MSGLIB_SQLITE_DLL`, `ISPHERE_MSGLIB_DB`, and optional `ISPHERE_MSGLIB_PASSWORD`.
|
||||
- C28 still does not register a new MCP tool, does not read message bodies, does not return contact/group row values, and does not implement file download/send/write behavior.
|
||||
- Next gap: C29 must add a bounded display-entity operation before DB-backed contact/group display names can be exposed.
|
||||
|
||||
---
|
||||
|
||||
## Loop C29: Bounded `MsgLib.db` display entity extraction
|
||||
|
||||
**Goal:** Extend the sidecar/client boundary from schema/display-source availability to bounded contact/group display-entity metadata, so a later loop can enrich `isphere_search_contacts` and `isphere_search_groups` without returning raw rows, message bodies, file paths, downloads, sends, writes, hooks, injection, or DB mutations.
|
||||
|
||||
**Planned files:**
|
||||
- Modify: `native/MsgLibReadSidecar/Program.cs`
|
||||
- Modify: `docs/msglib-read-sidecar-contract.md`
|
||||
- Modify: `internal/msglib/sidecar_client.go`
|
||||
- Modify: `internal/msglib/sidecar_client_test.go`
|
||||
- Modify: `scripts/verify-msglib-sidecar.ps1`
|
||||
- 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:**
|
||||
- Add a sidecar operation tentatively named `display_entities`.
|
||||
- Request args: `sqlite_dll_path`, `db_path`, optional `password`, `entity_type` (`contacts` or `groups`), optional `query`, and bounded `limit`.
|
||||
- Response data: normalized metadata only, such as `entity_type`, `source_table`, `jid`, `display_name`, `confidence`, and `matched_columns`.
|
||||
- Never return message bodies, file paths, raw SQL row maps, attachment contents, send/write capabilities, or unbounded result sets.
|
||||
- Use tests first. Normal Go tests should still use fake sidecar data; real copied DB verification stays opt-in through script/env paths.
|
||||
|
||||
- [ ] **Step 1: Write failing display-entity contract tests**
|
||||
|
||||
Add sidecar/client tests for bounded contact/group entity decoding, query/limit validation, and rejection of unsupported entity types.
|
||||
|
||||
- [ ] **Step 2: Implement sidecar `display_entities` operation**
|
||||
|
||||
Implement allowlisted table/column reads only for contact/group identity metadata, with parameterized query/limit and no raw row dumps.
|
||||
|
||||
- [ ] **Step 3: Extend Go client and verification script**
|
||||
|
||||
Add Go wrapper types/methods and optional evidence-backed verification that reports only counts/source-table names, not personal values.
|
||||
|
||||
- [ ] **Step 4: Update docs, run full verification, and commit**
|
||||
|
||||
Run:
|
||||
|
||||
```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
|
||||
|
||||
Reference in New Issue
Block a user