feat: harden send file idempotency audit
This commit is contained in:
@@ -594,19 +594,19 @@ git push gitea main
|
||||
- Duplicate same target/file/idempotency returns `duplicate_detected=true` with no second send.
|
||||
- Reusing the same idempotency key for a different target or file hash returns `conflict_detected=true`.
|
||||
|
||||
- [ ] **Step 1: Write duplicate test**
|
||||
- [x] **Step 1: Write duplicate test**
|
||||
|
||||
Add `TestISphereSendFileDuplicateIdempotencyDetected`: same target, same file hash, same idempotency key called twice; second response has `duplicate_detected=true` and `real_send_attempted=false`.
|
||||
|
||||
- [ ] **Step 2: Write conflict test**
|
||||
- [x] **Step 2: Write conflict test**
|
||||
|
||||
Add `TestISphereSendFileIdempotencyConflictBlocked`: same idempotency key with a different file hash returns `send_status="blocked"` and `conflict_detected=true`.
|
||||
|
||||
- [ ] **Step 3: Implement audit and idempotency state**
|
||||
- [x] **Step 3: Implement audit and idempotency state**
|
||||
|
||||
Reuse the message idempotency pattern or extract a shared small helper only if it reduces duplication without changing message behavior.
|
||||
|
||||
- [ ] **Step 4: Verify and commit**
|
||||
- [x] **Step 4: Verify and commit**
|
||||
|
||||
```powershell
|
||||
git diff --check
|
||||
@@ -621,6 +621,15 @@ git push gitea main
|
||||
|
||||
**Acceptance gate:** File upload remains blocked, but duplicate/conflict behavior is deterministic.
|
||||
|
||||
**R8 Result:**
|
||||
|
||||
- Added send-file audit and idempotency state with `ISPHERE_SEND_FILE_AUDIT_PATH` and `ISPHERE_SEND_FILE_IDEMPOTENCY_PATH`.
|
||||
- Duplicate same target/file/idempotency key now returns `duplicate_detected=true` and remains planned/no-send.
|
||||
- Reusing the same idempotency key for a different target or file hash returns `send_status="blocked"` and `conflict_detected=true`.
|
||||
- Send-file audit/idempotency JSONL stores file hash, size, target ref, result, side-effect flags, and hashed idempotency key; it does not store raw file content, raw local file path, or raw idempotency key.
|
||||
- `scripts/verify-go-mcp.ps1` now asserts `send_file_duplicate_detected=true` and `send_file_conflict_blocked=true` while keeping `send_file_production_enabled=false`.
|
||||
- Verification passed: `git diff --check`, `go test ./internal/tools -run TestISphereSendFile -v`, `go test ./...`, `go build ./cmd/isphere-mcp`, `scripts\verify-go-mcp.ps1`, and `go run ./cmd/isphere-capability-smoke`.
|
||||
|
||||
---
|
||||
|
||||
### R9: Send-file upload evidence package
|
||||
|
||||
Reference in New Issue
Block a user