Files

88 lines
3.8 KiB
Markdown

---
phase: "14"
plan: "06"
type: execute
wave: 5
depends_on:
- "14-03"
- "14-05"
files_modified:
- backend/api/cloud/operations.py
- backend/services/cloud_byte_cache.py
- backend/api/cloud/schemas.py
- backend/tests/test_cloud_cache.py
- backend/tests/test_cloud_security.py
- frontend/src/views/__tests__/CloudFolderOpenPreview.test.js
autonomous: true
requirements:
- CACHE-03
- CACHE-04
- CACHE-05
---
<objective>
Route cloud open/preview byte hydration through the Phase 14 byte cache so opening and previewing use the same bounded, owner-scoped, quota-counted cache lifecycle as analysis.
Scope fence: do not change the shared browser analysis queue; this plan only updates existing content routes and their tests.
</objective>
<context>
@.planning/phases/13-virtual-local-cloud-operations/13-CONTEXT.md
@.planning/phases/14-selective-analysis-and-byte-cache/14-PATTERNS.md
@backend/api/cloud/operations.py
@backend/services/cloud_byte_cache.py
@frontend/src/views/CloudFolderView.vue
</context>
<tasks>
<task type="auto">
<name>Task 1: Update backend open/preview/download routes to use cache leases</name>
<files>backend/api/cloud/operations.py, backend/services/cloud_byte_cache.py, backend/tests/test_cloud_cache.py, backend/tests/test_cloud_security.py</files>
<read_first>
- backend/api/cloud/operations.py
- backend/services/cloud_byte_cache.py
- backend/storage/cloud_backend_factory.py
</read_first>
<action>
Modify authorized cloud content routes so provider bytes are hydrated into the cache on demand, pinned during active streaming/preview, last-accessed timestamp is updated, and eviction runs after release when needed. Preserve binary-only preview enforcement and no raw provider URL exposure. Existing download fallback remains authorized through DocuVault, not a provider URL.
</action>
<acceptance_criteria>
- Preview/open/download never serve bytes without owner-scoped connection/item resolution.
- Cache hits avoid provider byte fetch.
- Active preview/download cache entries are not evicted mid-response.
- Responses still omit object keys, credentials, and raw provider URLs.
</acceptance_criteria>
<verify><automated>cd backend && pytest -q tests/test_cloud_cache.py tests/test_cloud_security.py -k "preview or download or cache"</automated></verify>
</task>
<task type="auto">
<name>Task 2: Preserve frontend open/preview behavior against cached backend</name>
<files>frontend/src/views/__tests__/CloudFolderOpenPreview.test.js</files>
<read_first>
- frontend/src/views/CloudFolderView.vue
- frontend/src/api/cloud.js
- frontend/src/views/__tests__/CloudFolderOpenPreview.test.js
</read_first>
<action>
Update frontend tests only if route response metadata changes. Preserve the invariant that `CloudFolderView` calls `api.openCloudFile`/`previewCloudFile` and never opens provider URLs directly. Add assertions that cache-related response fields, if any, do not leak object keys.
</action>
<acceptance_criteria>
- Existing open/preview tests remain green.
- No browser-to-provider URL path is introduced.
- Cache semantics remain backend-owned and do not require frontend object-key knowledge.
</acceptance_criteria>
<verify><automated>cd frontend && npm run test -- CloudFolderOpenPreview.test.js</automated></verify>
</task>
</tasks>
<verification>
1. `cd backend && pytest -q tests/test_cloud_cache.py tests/test_cloud_security.py -k "cache or preview or download"`
2. `cd frontend && npm run test -- CloudFolderOpenPreview.test.js`
3. `rg "window.open|provider_url|object_key" frontend/src/views/CloudFolderView.vue frontend/src/api/cloud.js backend/api/cloud/operations.py`
</verification>
<output>Create `.planning/phases/14-selective-analysis-and-byte-cache/14-06-SUMMARY.md` when complete.</output>