feat: filter receive messages by conversation and query

This commit is contained in:
zhaoyilun
2026-07-10 01:22:17 +08:00
parent bbffa2189d
commit e7324d8aa6
9 changed files with 181 additions and 21 deletions

View File

@@ -1573,19 +1573,19 @@ Implemented and verified in this loop:
- Preserve current empty-source behavior and current `limit` behavior.
- Do not add write/send/file-download behavior.
- [ ] **Step 1: Write failing source/query test**
- [x] **Step 1: Write failing source/query test**
Extend `internal/isphere/source_test.go` with redacted fixtures proving `conversation_id` and keyword filtering.
- [ ] **Step 2: Implement source query filtering**
- [x] **Step 2: Implement source query filtering**
Apply filters after decrypt/parse/normalize and before limit truncation, keeping deterministic source order.
- [ ] **Step 3: Wire MCP args and verification**
- [x] **Step 3: Wire MCP args and verification**
Expose `conversation_id` and `query` on `isphere_receive_messages`, update tool tests and `verify-go-mcp.ps1` synthetic smoke.
- [ ] **Step 4: Run full verification and commit**
- [x] **Step 4: Run full verification and commit**
Run:
@@ -1600,6 +1600,67 @@ Expected: all exit 0. Remove any generated root `isphere-mcp.exe` after build. C
---
## Loop C18 Result
Implemented and verified in this loop:
- `isphere.ReceiveMessagesQuery` now supports `ConversationID` and `Query` in addition to `Limit`.
- `EncryptedPacketLogSource.ReceiveMessages` filters normalized messages by exact conversation id and case-insensitive keyword match over message id, conversation id, sender id, receiver id, text, subject, and receipt id.
- `isphere_receive_messages` MCP args now accept `conversation_id` and `query`, and pass them through to the source.
- `scripts/verify-go-mcp.ps1` now calls configured file and directory source smokes with `conversation_id` plus keyword query arguments.
- Existing empty-source and limit behavior remains unchanged.
---
## Loop C19: Receive-message `since` time filter slice
**Goal:** Add the next safe receive-message filter from the core contract: `since`, using ISO-8601 input from the MCP caller and PacketReader epoch-millisecond timestamps from the normalized local readonly source.
**Planned files:**
- Modify: `internal/isphere/source.go`
- Modify: `internal/isphere/source_test.go`
- Modify: `internal/tools/isphere_read.go`
- Modify: `internal/tools/isphere_read_test.go`
- Modify: `scripts/verify-go-mcp.ps1`
- Modify: `docs/go-mcp-runbook.md`
- Modify: `docs/current-status-card.md`
- Modify: `docs/superpowers/plans/2026-07-09-stage-c-log-backed-receive-messages-loop.md`
**Planned behavior:**
- Add `Since` to `ReceiveMessagesQuery` and `ReceiveMessagesArgs`.
- Accept RFC3339/ISO-8601 input for `since`.
- Compare against message `Timestamp` when it is an epoch-millisecond value.
- Return a clear error for invalid `since` input rather than silently ignoring it.
- Keep `cursor`, `source_preference`, and broader pagination deferred.
- Do not add write/send/file-download behavior.
- [ ] **Step 1: Write failing source `since` test**
Use synthetic PacketReader fixtures before and after an RFC3339 threshold.
- [ ] **Step 2: Implement source `since` filtering**
Parse `since` once per receive call and filter normalized messages by timestamp.
- [ ] **Step 3: Wire MCP args and verification**
Expose `since` on `isphere_receive_messages`, update tool tests and `verify-go-mcp.ps1` synthetic smoke.
- [ ] **Step 4: Run full verification and commit**
Run:
```powershell
git diff --check
go test ./...
go build ./cmd/isphere-mcp
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/verify-go-mcp.ps1
```
Expected: all exit 0. Remove any generated root `isphere-mcp.exe` after build. Commit exact C19 paths only and rewrite the next loop from actual results.
---
## Self-Review
- Spec coverage: the plan follows the user's cyclic requirement: plan first, implement one loop at a time, update the next loop after each result, and ask only on blockers.