feat(api): batch-scoped processing summary + upload-batch completion notifications #801

Merged
chris merged 1 commit from feat/upload-batch-notifications into main 2026-09-21 21:43:17 +02:00
Owner

Summary

Implements the API half of the approved design (docs/superpowers/specs/2026-09-21-upload-batch-activity-notifications-design.md):

  • V132: upload_sessions.notified_at watermark (backfilled so existing sessions start quiet) + supporting partial indexes.
  • V133: user_notifications type check relaxed for upload_batch_completed (constraint name verified against live DB).
  • GET /api/processing-summary gains recentBatch {active, sessionCount, activities[]} scoped to the owner's unnotified sessions with committed media; all existing lifetime fields unchanged. Lane definitions shared via new ProcessingActivityLanes.
  • New UploadBatchCompletionService + AFTER_COMMIT listener on WorkerJobCompletedEvent: when all post-commit jobs of a session are terminal, atomically claims the watermark and inserts ONE upload_batch_completed notification (uploadedCount + per-lane finished/failed, sorted by label); duplicate-only sessions get the watermark without a notification. Final commit also finalizes batches whose jobs completed early.
  • SSE: notifications_changed (new) + processing_summary_changed after watermark update.
  • Bug fix found during implementation: /api/user/notifications* endpoints scoped by session.ownerId() but user_notifications.user_id references user_accounts(id) - domain notifications were never listable/dismissable. Now scoped by session.userAccountId(), matching the activate-domain endpoint (controller tests updated).
  • KNOWN_ISSUES: ISSUE-059 (recovery-terminalized jobs do not fire completion events), ISSUE-060 (never-committed sessions keep batch visible).

Verification

  • rtk ./gradlew :apps:api:build: BUILD SUCCESSFUL
  • Full :apps:api:test: green (with raised test-worker heap; host memory-starved during run, OOMs were environmental - see verification notes)
  • New/extended tests: UploadBatchCompletionServiceTest, UploadBatchNotificationMigrationTest, ProcessingSummaryServiceTest, UploadCommitServiceTest, UserDiscoveryControllerTest

Companion web PR renders recentBatch in the activity dialog and the new notification type in the bell.

## Summary Implements the API half of the approved design (docs/superpowers/specs/2026-09-21-upload-batch-activity-notifications-design.md): - V132: upload_sessions.notified_at watermark (backfilled so existing sessions start quiet) + supporting partial indexes. - V133: user_notifications type check relaxed for upload_batch_completed (constraint name verified against live DB). - GET /api/processing-summary gains recentBatch {active, sessionCount, activities[]} scoped to the owner's unnotified sessions with committed media; all existing lifetime fields unchanged. Lane definitions shared via new ProcessingActivityLanes. - New UploadBatchCompletionService + AFTER_COMMIT listener on WorkerJobCompletedEvent: when all post-commit jobs of a session are terminal, atomically claims the watermark and inserts ONE upload_batch_completed notification (uploadedCount + per-lane finished/failed, sorted by label); duplicate-only sessions get the watermark without a notification. Final commit also finalizes batches whose jobs completed early. - SSE: notifications_changed (new) + processing_summary_changed after watermark update. - Bug fix found during implementation: /api/user/notifications* endpoints scoped by session.ownerId() but user_notifications.user_id references user_accounts(id) - domain notifications were never listable/dismissable. Now scoped by session.userAccountId(), matching the activate-domain endpoint (controller tests updated). - KNOWN_ISSUES: ISSUE-059 (recovery-terminalized jobs do not fire completion events), ISSUE-060 (never-committed sessions keep batch visible). ## Verification - rtk ./gradlew :apps:api:build: BUILD SUCCESSFUL - Full :apps:api:test: green (with raised test-worker heap; host memory-starved during run, OOMs were environmental - see verification notes) - New/extended tests: UploadBatchCompletionServiceTest, UploadBatchNotificationMigrationTest, ProcessingSummaryServiceTest, UploadCommitServiceTest, UserDiscoveryControllerTest Companion web PR renders recentBatch in the activity dialog and the new notification type in the bell.
feat(api): batch-scoped processing summary + upload-batch completion notifications
All checks were successful
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 3m39s
0322735a01
Add upload_sessions.notified_at as the batch watermark (V132, backfilled to
COALESCE(completed_at, updated_at, created_at) so existing sessions start
quiet) and relax the user_notifications type check for
upload_batch_completed (V133).

GET /api/processing-summary now exposes recentBatch (active, sessionCount,
per-lane counts) scoped to the owner's unnotified sessions with committed
media; all existing top-level fields keep their lifetime semantics. Lane
definitions are shared via ProcessingActivityLanes.

UploadBatchCompletionService atomically claims the watermark and creates one
upload_batch_completed notification per session with sorted finished/failed
lane counts; duplicate-only sessions get the watermark without a notification.
It is triggered by UploadBatchCompletionListener on WorkerJobCompletedEvent
(AFTER_COMMIT, own transaction) and by the final upload commit, so batches
whose jobs finished before the final commit are still notified. SSE emits
notifications_changed and processing_summary_changed.

Also scope list/dismiss/update of /api/user/notifications by the session user
account: user_notifications.user_id references user_accounts(id), so the
previous owner-profile filter could never match (notifications were invisible
and un-dismissable).

Refs: docs/superpowers/specs/2026-09-21-upload-batch-activity-notifications-design.md
chris merged commit 77189b00c1 into main 2026-09-21 21:43:17 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!801
No description provided.