feat: add receive file download preview contract

This commit is contained in:
zhaoyilun
2026-07-11 00:31:33 +08:00
parent 6164703a9a
commit 57db83d36c
6 changed files with 314 additions and 22 deletions

View File

@@ -803,19 +803,19 @@ Created `docs/source-discovery/2026-07-10-returned-send-sent-record-diagnostic.m
- If resolver lacks accepted mapping, response: `ok=false`, `download_status="blocked"`, `blocked_reason_code="file_cache_mapping_missing"`.
- If resolver has accepted mapping in fixture tests, response: `ok=true`, `download_status="planned"`, no file copy during preview.
- [ ] **Step 1: Write blocked-preview test**
- [x] **Step 1: Write blocked-preview test**
Add `TestISphereReceiveFilesDownloadPreviewBlockedWithoutMapping`, asserting `blocked_reason_code="file_cache_mapping_missing"` and `file_contents_read=false`.
- [ ] **Step 2: Write planned-preview fixture test**
- [x] **Step 2: Write planned-preview fixture test**
Add `TestISphereReceiveFilesDownloadPreviewPlannedWithFixtureMapping`, using an injected fixture resolver and asserting `download_status="planned"`, `file_contents_read=false`, and `file_copied=false`.
- [ ] **Step 3: Implement preview contract**
- [x] **Step 3: Implement preview contract**
Keep non-preview real download blocked unless R10 accepted mapping exists and a separate production-copy gate is added.
- [ ] **Step 4: Verify and commit**
- [x] **Step 4: Verify and commit**
```powershell
git diff --check
@@ -830,6 +830,15 @@ git push gitea main
**Acceptance gate:** 数字员工可以理解“为什么现在不能下载”,并在有映射时得到 planned preview。
**R11 Result:**
- Actual implementation files are `internal/tools/isphere_files.go` and `internal/tools/isphere_files_test.go`.
- Added structured download preview blocked response for missing mapping.
- Added injected fixture resolver test for planned preview.
- Standard MCP smoke now reports `receive_file_download_preview_blocked=true`.
- Real file copy/download remains blocked; preview reads no file contents and returns no raw paths.
---
### R12: Receive-message reconciliation helper