---
context: phase
phase: 03-document-migration-multi-user-isolation
task: UAT-in-progress
total_tasks: 10
status: in_progress
last_updated: 2026-05-24T19:25:23Z
---

# BLOCKING CONSTRAINTS — Read Before Anything Else

> These are not suggestions. Each constraint below was discovered through failure.
> Acknowledge each one explicitly before proceeding.

- [ ] CONSTRAINT: XHR-MINIO-CORS — The XHR PUT to MinIO from the browser fails with a network error ("Network Problem"). Root cause not yet confirmed — need browser DevTools console output (CORS error vs connection refused vs 4xx). Do NOT assume it's fixed until user confirms upload works.
- [ ] CONSTRAINT: UAT-PARTIAL — The Phase 3 UAT session is in progress (03-UAT.md exists). Tests 3–10 are pending. Do NOT mark Phase 3 complete until UAT is finished and all blockers resolved.

**Do not proceed until all boxes are checked.**

## Critical Anti-Patterns

| Pattern | Description | Severity | Prevention Mechanism |
|---------|-------------|----------|---------------------|
| Auth 401 intercept on login | `request()` in api/client.js was intercepting 401 from the login endpoint and trying to refresh — throwing "Session expired" instead of real error | advisory | noRefreshPaths exclusion now in place; already fixed |
| Router sync-only guard | `router.beforeEach` was synchronous — on page reload access token is null (memory-only), guard redirected to /login before refresh cookie could restore session | advisory | Fixed: guard is now async and attempts refresh() before redirecting |

<current_state>
Phase 3 UAT is in progress. Two bugs found and fixed this session:
1. Login "Session expired" bug — fixed in frontend/src/api/client.js (noRefreshPaths exclusion)
2. Re-login on page reload — fixed in frontend/src/router/index.js (async beforeEach with refresh())

One bug is OPEN and blocking UAT test 2 (upload with XHR progress bar):
- Uploading a file shows "Network Problem" error
- The document appears as PENDING after switching topics (upload-url step worked, XHR PUT failed)
- No quota update (fetchQuota never called because upload threw before that)
- Root cause: XHR PUT to MinIO at localhost:9000 is failing — likely CORS preflight or connectivity issue
- NEXT ACTION: Ask user to open browser DevTools (F12 → Console + Network tab), attempt upload, and paste what errors appear

Tests 2–10 are pending in the UAT file. Test 7 (admin blocked from doc content) was marked pass from user observation.
</current_state>

<completed_work>

This session (UAT + bug fixes):
- Created `.planning/phases/03-document-migration-multi-user-isolation/03-UAT.md` with 10 tests
- Test 1 (Cold Start Smoke Test): PASS
- Test 7 (Admin blocked from document content): PASS — "Admin accounts cannot access document content" correct behavior
- Fixed BUG-1: Login shows "Session expired" on wrong credentials
  - Root cause: `request()` intercepts 401 from /api/auth/login and tries refresh → throws "Session expired"
  - Fix: `noRefreshPaths = ['/api/auth/login', '/api/auth/register', '/api/auth/refresh']` in client.js:24
  - Verified: user confirmed login now works
- Fixed BUG-2: Re-login required on every page reload
  - Root cause: `router.beforeEach` was sync, no refresh attempt — access token gone after reload
  - Fix: Made `beforeEach` async, attempts `authStore.refresh()` before redirecting to /login
  - Not yet verified by user (fix applied at end of session)
</completed_work>

<remaining_work>

IMMEDIATE — before resuming UAT:
1. Ask user to open DevTools Console + Network tab, attempt upload, paste the error
2. Diagnose XHR PUT failure (likely one of):
   - CORS preflight blocked: MinIO not returning Access-Control-Allow-Origin for PUT
   - MinIO not accessible at localhost:9000 from browser
   - Content-Type mismatch in presigned URL signature vs XHR header
3. Apply fix based on console output
4. Verify upload works (progress bar, document appears with status=uploaded, not pending)
5. Verify QuotaBar updates after upload

THEN continue UAT:
- Test 2 (Upload with XHR progress bar) — re-test after fix
- Test 3 (QuotaBar displays in sidebar) — should work after upload fix
- Test 4 (Quota rejection error block) — need user to set very small quota via admin
- Test 5 (Quota decrements on delete)
- Test 6 (Cross-user document isolation — 404 not 403)
- Test 8 (Topics namespace-scoped)
- Test 9 (Settings page static placeholder)
- Test 10 (AI classification uses per-user provider)
</remaining_work>

<decisions_made>

- noRefreshPaths exclusion pattern: auth endpoints that return 401 for bad credentials (not expired tokens) must skip the auto-refresh logic in request()
- Router beforeEach made async to support silent session restore on page reload — this is the standard SPA pattern for httpOnly refresh token cookies
- "Network Problem" root cause not yet confirmed — need console output before applying a fix (don't guess)
</decisions_made>

<blockers>

- XHR PUT to MinIO fails — "Network Problem" in browser. User needs to provide browser console output to confirm root cause. Likely CORS or connectivity issue with localhost:9000.
- UAT tests 3–10 blocked behind Test 2 (upload must work first for quota, isolation, and topic tests)
</blockers>

## Required Reading (in order)

1. `.planning/phases/03-document-migration-multi-user-isolation/03-UAT.md` — current UAT state (tests, gaps, fixes applied)
2. `frontend/src/api/client.js` lines 20–35 — the noRefreshPaths fix applied this session
3. `frontend/src/router/index.js` lines 50–60 — the async beforeEach fix applied this session
4. `frontend/src/stores/documents.js` — upload() function: 3-step flow, where "Network Problem" originates

## Infrastructure State

- docker compose: should be running (user did cold start smoke test — Test 1 passed)
- Frontend dev server: `cd frontend && npm run dev` on localhost:5173
- MinIO: accessible at localhost:9000 (port mapped in docker-compose) — BUT browser XHR PUT failing
- Test account: `testuser@docuvault.example` / `TestUser1234!` — confirmed working after login fix

## Pre-Execution Critique Required

N/A — not pausing between design and execution.

<context>
We are doing UAT for Phase 3 (Document Migration & Multi-User Isolation). Phase 3 had all 5 plans executed with SUMMARY files. The checkpoint from Plan 03-05 required browser testing, which we started doing.

Two bugs were found and fixed:
1. Login error message bug (noRefreshPaths in client.js)
2. Session restore on page reload (async router guard)

The upload flow (XHR PUT to MinIO) is broken in the browser but we ran out of context before diagnosing it. The document store's uploadToMinIO() function rejects with "Network error during upload" when the XHR onerror fires. The user sees "Network Problem" (likely paraphrasing). The MinIO CORS config is set via MINIO_API_CORS_ALLOW_ORIGIN env var in docker-compose, but something isn't working.

The PENDING document appearing in the list is because the upload-url endpoint creates a Document row with status='pending' before the XHR PUT. If the XHR fails, confirm is never called, but the pending row may still be returned by the list endpoint.
</context>

<next_action>
Start with: Ask user to open browser DevTools (F12), go to Console and Network tabs, attempt to upload a file, then paste:
1. Any red errors in Console (especially CORS errors)
2. The failed network request in Network tab (URL, status code, response)

This will tell us exactly what's failing in the MinIO PUT.
</next_action>
