feat: filter receive messages by since

This commit is contained in:
zhaoyilun
2026-07-10 01:27:27 +08:00
parent e7324d8aa6
commit aa636f5a33
9 changed files with 164 additions and 14 deletions

View File

@@ -1634,19 +1634,19 @@ Implemented and verified in this loop:
- Keep `cursor`, `source_preference`, and broader pagination deferred.
- Do not add write/send/file-download behavior.
- [ ] **Step 1: Write failing source `since` test**
- [x] **Step 1: Write failing source `since` test**
Use synthetic PacketReader fixtures before and after an RFC3339 threshold.
- [ ] **Step 2: Implement source `since` filtering**
- [x] **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**
- [x] **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**
- [x] **Step 4: Run full verification and commit**
Run:
@@ -1661,6 +1661,65 @@ Expected: all exit 0. Remove any generated root `isphere-mcp.exe` after build. C
---
## Loop C19 Result
Implemented and verified in this loop:
- `isphere.ReceiveMessagesQuery` now supports `Since` in addition to `ConversationID`, `Query`, and `Limit`.
- `EncryptedPacketLogSource.ReceiveMessages` accepts RFC3339/RFC3339Nano `since` input, compares it against PacketReader epoch-millisecond message timestamps, and returns only messages at or after the threshold.
- Invalid `since` input now returns an explicit error instead of being silently ignored.
- `isphere_receive_messages` MCP args now accept `since` and pass it through to the source.
- `scripts/verify-go-mcp.ps1` now calls configured file and directory source smokes with `conversation_id`, `query`, and `since`.
---
## Loop C20: Receive-message remaining contract argument validation
**Goal:** Make `isphere_receive_messages` friendlier to contract-following digital employees by accepting the remaining safe read-contract parameters with explicit validation, while keeping unsupported pagination/source behavior honest.
**Planned files:**
- 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 MCP args for `include_attachment_metadata`, `source_preference`, `preview`, and `cursor`.
- Accept `source_preference` empty, `auto`, or `local_readonly`; reject bridge/uia/network until those connectors exist.
- Accept empty `cursor`; reject non-empty cursor until pagination is implemented.
- Treat `preview` as read-only/no mutation and keep the audit `execution_mode` as `read`.
- Treat `include_attachment_metadata=false` as a request to suppress inline receive-message attachments while leaving `isphere_receive_files` available for explicit file listing.
- Do not add write/send/file-download behavior.
- [ ] **Step 1: Write failing MCP argument validation tests**
Extend `internal/tools/isphere_read_test.go` with accepted safe args and rejected unsupported source/cursor cases.
- [ ] **Step 2: Implement argument validation and attachment toggle**
Add minimal validation/helpers in `internal/tools/isphere_read.go`.
- [ ] **Step 3: Update verification and docs**
Update `scripts/verify-go-mcp.ps1`, runbook, status card, and this plan.
- [ ] **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 C20 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.