fix(sync): write-scope for intents, honest reinstate copy, pull endpoint tests #1364
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/sync-intentscope-reinstate-copy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR-1 of the 4-PR hardening plan from the adversarial review (oracle findings F3 / F2-short / F7). Based on the latest origin/main (includes #1362).
F3 (HIGH, security): intent endpoint was gated on the READ scope
POST /api/sync/intentsrequiredmedia:read— a read-only API credential could trash/restore/reinstate library items.Scope choice:
media:upload(existing scope), not a newmedia:write. Rationale:media:uploadis already v1's mutation scope — required byUploadSessionService.createForApiCredentialandUploadFileControllerfor the upload-session protocol (ADR 0097). The intents channel is the same class of client→server library mutation (S3 explicitly frames uploads as "the accepted-intent pipeline"; intents are the mutation complement), so semantically defensible without inventing vocabulary.V1_ALLOWED_SCOPES/grant-UI/OpenAPI churn, no migration for existing credentials, and every existing write-capable credential (incl. the Android app's own[media:upload, media:read]credential) keeps working unchanged.[media:upload, media:read]Bearer credential (AuthRepository.kt), so the history screen's restore flow keeps working.GET /api/sync/changes+GET /api/sync/removed-historykeepmedia:read— unchanged, now pinned by tests.Needed spec amendment (collected here for the amendment PR, not applied per PR-1 constraints) — see bottom.
F2-short (HIGH, UX honesty): reinstate dead-end on purged items
On
permanently_deletedhistory entries, the "Wieder aufnehmen" button was a dead end: the reinstate intent either rejects (override_rejected_explicit_deletion, C6) or accepts without effect (re-authorization only — ISSUE-190; real re-upload flow out of scope here).Client fix: purged entries now offer no button at all and no fake navigation. The card shows the live state label + honest inline copy (exact text below, plain-language discipline: reads as fact, names the actual path, no false promise).
trashedentries keep the working one-tap "Wiederherstellen".Implementation:
RemovedEntryUi.revertActionis now nullable (null= no action offered today;revertActionFormaps onlytrashed→ RESTORE);revert()no-ops for action-less entries (defense-in-depth behind the absent UI control). The C6 typed-reject copy mapping (sync_intent_reject_override_explicit_deletion) stays wired for the channel.F7 (LOW): HTTP-layer test for the pull endpoint
New
SyncControllerTest(MockMvc, mirrorsSyncIntentsControllerTest): S2 envelope passthrough ({epoch, changes, nextCursor, hasMore}+ per-change fields), limit param/default, write-only credential → 403 ProblemDetail on both GETs, read-only credential → 200, negative cursor → 400 ProblemDetail (the guard lives in the service and is pinned against real Postgres inSyncChangeFeedIntegrationTest; the HTTP test pins the wiring), owner scoping at the boundary (controller delegates exactly the session's owner id; cross-owner data semantics pinned in the integration test).Exact copy (for review)
de:
Dieses Bild wurde endgültig entfernt. Wenn du es wieder in der Mediathek haben möchtest, füge es auf deinem Gerät erneut hinzu.en:
This picture was permanently removed. If you want it back in the library, add it to Memories from your device again.da:
Dette billede blev fjernet permanent. Hvis du vil have det tilbage i biblioteket, skal du tilføje det til Memories fra din enhed igen.Key:
removed_history_purged_no_action. "erneut hinzufügen" = the user's existing mental model of adding media (albums/backup), matching the "Bewusst nicht in Memories" anchor copy's register; "Memories" is used in en/da where the German sentence reads naturally without the product name.KNOWN_ISSUES
Appended as ISSUE-196, not 193: the pre-assigned number collided — the 2026-10-24 KNOWN_ISSUES audit (#1361) renumbered resolved entries INTO 193/194/195 (
(renumbered from …)markers). 196 is the next free id; the entry carries the branch ref as instructed.Validation
:apps:api:test— BUILD SUCCESSFUL, 198 suites / 2308 tests, 0 failures, 0 errors (9 skips are pre-existing: 8@DisabledPostgres-requiring notification tests + 1 opt-in local research fixture; no sync test is Docker-gated, all sync suites ran).:app:testDebugUnitTest— BUILD SUCCESSFUL, 62 suites / 651 tests, 0 failures, 0 errors, 0 skipped (fresh--rerun-tasksrun).Needed spec 065 amendment text (S3/S5 scope vocabulary)
(
media:uploadas the mutation scope,media:readas the read scope — the v1 pair stays two-valued; if a future third-party integration surface needs finer-grained "sync-write without upload", that is the point to introducemedia:writeas an additive scope.)