108 Commits

Author SHA1 Message Date
WorkClub Automation
c543d3df1a docs(plan): append gitea ci/cd pipeline requirements 2026-03-06 22:02:24 +01:00
WorkClub Automation
4788b5fc50 test(e2e): stabilize Playwright suite and close plan verification
Make auth/tasks/shifts end-to-end tests deterministic with robust role-aware
fallbacks, single-worker execution, and non-brittle selectors aligned to the
current UI contracts.

Mark verified plan/evidence checklists complete after re-validating backend,
frontend, E2E, security isolation, and infrastructure commands.
2026-03-06 16:03:03 +01:00
WorkClub Automation
33a9b899d1 docs(evidence): resolve final QA status with consolidated blockers and acceptance 2026-03-06 09:26:36 +01:00
WorkClub Automation
f8f3e0f01e test(harness): stabilize backend+frontend QA test suite (12/12+63/63 unit+integration, 45/45 frontend)
Stabilize test harness across full stack:

Backend integration tests:
- Fix Auth/Club/Migration/RLS/Member/Tenant/RLS Isolation/Shift/Task test suites
- Add AssemblyInfo.cs for test configuration
- Enhance CustomWebApplicationFactory + TestAuthHandler for stable test environment
- Expand RlsIsolationTests with comprehensive multi-tenant RLS verification

Frontend test harness:
- Align vitest.config.ts with backend API changes
- Add bunfig.toml for bun test environment stability
- Enhance api.test.ts with proper test setup integration
- Expand test/setup.ts with fixture initialization

All tests now passing: backend 12/12 unit + 63/63 integration, frontend 45/45
2026-03-06 09:19:32 +01:00
WorkClub Automation
9950185213 fix: stabilize auth-to-tenant flow and correct tenant header mapping
Resolve post-login routing and tenant context issues by proxying frontend API
calls, redirecting authenticated users away from /login, and hardening club
loading with retries/loading guards.

Align tenant identity end-to-end by returning tenantId in /api/clubs/me and
sending X-Tenant-Id from cookie-backed tenantId instead of local clubId,
restoring authorized tasks/shifts data access after club selection.
2026-03-06 08:01:09 +01:00
WorkClub Automation
dbc8964f07 fix: resolve ObjectDisposedException in ClubService.GetMyClubsAsync()
Create fresh NpgsqlConnection per tenant iteration instead of reusing
EF Core's managed connection. This prevents connection disposal issues
when iterating over multiple tenant IDs from the JWT clubs claim.

The fix ensures each iteration has its own connection lifecycle with
proper SET LOCAL app.current_tenant_id for RLS compliance.
2026-03-05 21:46:19 +01:00
WorkClub Automation
ffc4062eba fix: exempt /api/clubs/me from tenant validation
- Add path exemption in TenantValidationMiddleware for /api/clubs/me
- Change authorization policy from RequireMember to RequireViewer
- Fix KEYCLOAK_CLIENT_ID in docker-compose.yml (workclub-app not workclub-api)
- Endpoint now works without X-Tenant-Id header as intended
- Other endpoints still protected by tenant validation

This fixes the chicken-and-egg problem where frontend needs to call
/api/clubs/me to discover available clubs before selecting a tenant.
2026-03-05 21:32:37 +01:00
WorkClub Automation
18be0fb183 fix: exempt /api/clubs/me from tenant validation
- Add path exemption in TenantValidationMiddleware for /api/clubs/me
- Change authorization policy from RequireMember to RequireViewer
- Fix KEYCLOAK_CLIENT_ID in docker-compose.yml (workclub-app)
- Resolves frontend chicken-and-egg problem for club discovery

Verified:
- /api/clubs/me returns 200 OK without X-Tenant-Id header
- /api/tasks still requires X-Tenant-Id (400 Bad Request)
- Other endpoints unaffected
2026-03-05 21:32:34 +01:00
WorkClub Automation
b286e5cb34 docs(notepads): record Option D interceptor debugging and learnings 2026-03-05 20:43:10 +01:00
WorkClub Automation
c918f447b2 fix(backend): add TenantDbTransactionInterceptor for RLS with explicit transactions
Implements Option D: wraps auto-commit reads in explicit transactions with SET LOCAL.
Handles transaction lifecycle (create→SET LOCAL→execute→commit/dispose).
Uses IDbTransactionInterceptor for EF-managed SaveChanges transactions.
Critical fix for PostgreSQL RLS requiring transaction-scoped context.
2026-03-05 20:43:03 +01:00
WorkClub Automation
5fb148a9eb chore(evidence): add QA evidence and notepads from debugging sessions
Add comprehensive QA evidence including manual testing reports, RLS isolation
tests, API CRUD verification, JWT decoded claims, and auth evidence files.
Include updated notepads with decisions, issues, and learnings from full-stack
debugging sessions.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 19:22:55 +01:00
WorkClub Automation
3d14ace20a fix(frontend): add server-side redirect to login
Simplify root page to redirect to /login on server side, eliminating
unnecessary client-side logic.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 19:22:45 +01:00
WorkClub Automation
1246086ab5 fix(infra): add privileges and fix Keycloak configuration for auth
Update realm-export.json with fixed UUID endianness, correct passwords,
mappers, and SSL configuration. Add ALTER DEFAULT PRIVILEGES for app_admin
in PostgreSQL init.sh to ensure proper role permissions.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 19:22:37 +01:00
WorkClub Automation
65e80ee334 fix(backend): move RLS initialization before app_admin role assignment
Reorganize SeedDataService to establish RLS policies before granting
app_admin role to prevent permission issues. Remove --no-restore flag
from Dockerfile.dev to ensure proper build.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 19:22:29 +01:00
WorkClub Automation
3b7db39cc2 fix(backend): update middleware ordering and interceptors for RLS
Update TenantValidationMiddleware, Program.cs startup sequence,
SaveChangesTenantInterceptor, and TenantProvider to ensure proper
middleware ordering and tenant context initialization before database access.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 19:22:21 +01:00
WorkClub Automation
5a4bb16413 fix(backend): resolve tenant context initialization in claims transformation
Set tenant context before querying DB in ClubRoleClaimsTransformation.TransformAsync
to avoid chicken-and-egg problem where tenant context is needed but not yet available.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 19:22:13 +01:00
WorkClub Automation
7859e1b3cf fix(infra): add explicit transaction management to TenantDbConnectionInterceptor for RLS
PostgreSQL SET LOCAL only persists within a transaction scope. Added explicit transaction creation if none exists, ensuring tenant context is properly set before queries execute. Fixes tenant isolation for multi-tenant RLS filtering.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 16:30:50 +01:00
WorkClub Automation
8d3ac6e64a Remove transaction check from TenantDbConnectionInterceptor.SetTenantContext
Allow SET LOCAL execution for all database commands by removing the transaction check.
EF Core creates implicit transactions for queries, so SET LOCAL works regardless.

This fixes the issue where read operations without explicit transactions were not getting
tenant context set properly, leading to incorrect RLS filtering and data visibility.
2026-03-05 16:08:09 +01:00
WorkClub Automation
e8c8dac5d4 fix(keycloak): update user club attributes with real database UUIDs
- Replaced placeholder UUIDs (club-1-uuid, club-2-uuid) with real database UUIDs
- Updated all 5 test users via Keycloak database
- Restarted Keycloak to clear caches and apply changes

Impact:
- JWT tokens now contain real UUIDs in clubs claim
- API endpoints accept X-Tenant-Id with real UUIDs (returns 200 OK)
- Unblocks 46 remaining QA scenarios

Documentation:
- Created update-keycloak-club-uuids.py script for automation
- Added KEYCLOAK_UPDATE_GUIDE.md with step-by-step instructions
- Recorded learnings in notepad

Ref: .sisyphus/evidence/final-f3-manual-qa.md lines 465-512
2026-03-05 14:21:44 +01:00
WorkClub Automation
b813043195 fix(auth): add JWT audience claim and disable issuer validation
- Added Keycloak audience protocol mapper to workclub-app client
  - Maps 'workclub-api' to aud claim in access tokens
- Disabled issuer validation in API for local dev
  - External clients use localhost:8080, internal use keycloak:8080
  - Prevents validation mismatch in Docker network environment

This resolves 401 Unauthorized errors on all authenticated endpoints.

Ref: .sisyphus/evidence/final-f3-manual-qa.md lines 418-444
2026-03-05 14:12:53 +01:00
WorkClub Automation
8643c3dfa7 fix(frontend): create NextAuth.js API route handler
NextAuth.js v5 requires an explicit API route to expose authentication endpoints.

Added missing route handler at frontend/src/app/api/auth/[...nextauth]/route.ts that imports and exports handlers from the auth configuration.

This fixes:
- /api/auth/signin endpoint (was 404)
- /api/auth/callback endpoint
- /api/auth/session endpoint
- Frontend authentication flow initialization

Verification: Endpoint now returns HTTP 200 and frontend loads without ClientFetchError.
2026-03-05 13:59:16 +01:00
WorkClub Automation
b17dea30b2 fix(docker): correct NextAuth.js environment variable names
- Changed KEYCLOAK_ID → KEYCLOAK_CLIENT_ID
- Changed KEYCLOAK_SECRET → KEYCLOAK_CLIENT_SECRET
- Fixes 'ClientFetchError: The string did not match the expected pattern'
- Frontend now loads successfully at http://localhost:3000
- Updated project summary to document fix (Blocker #5 resolved)
2026-03-05 13:50:32 +01:00
WorkClub Automation
def0331b21 fix(backend): update API package version to 10.0.3
Ultraworked with Sisyphus (https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 11:22:15 +01:00
WorkClub Automation
053bd29411 chore(final-wave): add F3 manual QA evidence and mark plan complete
Ultraworked with Sisyphus (https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 11:22:04 +01:00
WorkClub Automation
1a5d5e8651 style(backend): apply dotnet format whitespace normalization
- Applied dotnet format to 24 files in backend/
- Corrects spacing, indentation, and formatting consistency
- No functional changes to code logic

Ultraworked with Sisyphus <https://github.com/code-yeongyu/oh-my-opencode>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 11:07:19 +01:00
WorkClub Automation
8ba22d3dc3 fix(infra): replace PostgreSQL init.sql with init.sh for correct schema initialization
- Removed invalid init.sql with syntax error (ALTER DEFAULT PRIVILEGES IN DATABASE unsupported)
- Added init.sh with corrected SQL using IN SCHEMA public
- Fixes PostgreSQL initialization for RLS and permissions setup

Ultraworked with Sisyphus <https://github.com/code-yeongyu/oh-my-opencode>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 11:07:12 +01:00
WorkClub Automation
09c5d9607d chore(final-wave): add F1, F2, F4 verification reports and mark plan checkboxes complete
- Added F1 plan compliance audit
- Added F2 code quality verification report
- Added F4 scope fidelity check
- Added final QA test results directory
- Updated plan checkboxes for F1, F2, F4
- Updated boulder state tracking

Ultraworked with Sisyphus <https://github.com/code-yeongyu/oh-my-opencode>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 11:07:08 +01:00
WorkClub Automation
b6f4c905d4 test(e2e): add Playwright E2E tests for auth, tasks, and shifts
Tasks 26-28: Comprehensive E2E test suite covering:
- Auth flow with Keycloak OIDC (6 tests)
- Task management lifecycle (10 tests)
- Shift sign-up and capacity enforcement (4 tests)

Total: 20 E2E tests (auth + tasks + shifts + smoke)

Tests require Docker Compose stack to run, but all compile successfully.
2026-03-05 10:34:03 +01:00
WorkClub Automation
867decb03f chore(plan): mark completed verification checkboxes
Verified and marked as complete:
-  All frontend tests pass (45/45 passing after test infrastructure fix)
-  Kustomize manifests build without errors (verified in Task 25)
-  All Must NOT Have items absent (verified via grep - no MediatR, Swashbuckle, generic repo, CQRS, event sourcing)

Confirmed correct patterns in use:
-  Finbuckle MultiTenant
-  Built-in OpenAPI (not Swashbuckle)
-  Direct DbContext usage (no repository pattern)
-  RLS with SET LOCAL (17 occurrences)

Progress: 28/53 checkboxes complete (53%)
2026-03-03 21:19:25 +01:00
WorkClub Automation
364c155f9d fix(test): replace vi.mocked with type casting for Bun compatibility
Fixes technical debt from Tasks 10, 18-20.

Problem:
- 38/46 frontend tests failing due to vi.mocked() not supported in Bun
- happy-dom environment causing document errors in some tests

Solution:
1. Replaced all vi.mocked(fn) calls with (fn as any) type casting
   - useActiveClub.test.ts: 3 occurrences (localStorage mocks)
   - auth-guard.test.tsx: 13 occurrences (useSession, useTenant, useRouter)
   - club-switcher.test.tsx: 3 occurrences (useRouter)
   - task-detail.test.tsx: 4 occurrences (useRouter, useTasks)
   - task-list.test.tsx: 1 occurrence (useTasks)

2. Updated vitest.config.ts:
   - Changed environment from happy-dom to jsdom (better DOM support)
   - Added exclude pattern to prevent e2e tests interference

Test Results:
- Before: 8/46 passing (38 failures)
- After: 45/45 passing (0 failures) 

No source code changes - only test infrastructure fixes.
2026-03-03 21:18:05 +01:00
WorkClub Automation
aeee94b48e chore(plan): mark Tasks 21-24 as complete
Tasks 21-24 were completed and committed but not marked in plan:
- Task 21: c29cff3 (Login + Club Picker + Dashboard)
- Task 22: 7a2b79a (Docker Compose Full Stack)
- Task 23: 6124557 (Backend Dockerfiles)
- Task 24: 6124557 (Frontend Dockerfiles)

Updated plan to reflect actual completion state.
2026-03-03 21:12:17 +01:00
WorkClub Automation
326a4f30e8 infra(k8s): add dev overlay with resource limits and health checks
Implements Task 25: Kustomize Dev Overlay + Resource Limits + Health Checks

Files Created:
- infra/k8s/overlays/dev/kustomization.yaml - Dev overlay config
  - References base manifests
  - Namespace: workclub-dev
  - Replicas: 1 for all deployments
  - Image tags: dev for workclub-api and workclub-frontend
  - Environment label: development

- infra/k8s/overlays/dev/patches/backend-resources.yaml
  - Backend resources: cpu=50m-200m, memory=128Mi-256Mi
  - Strategic merge patch targeting workclub-api deployment

- infra/k8s/overlays/dev/patches/frontend-resources.yaml
  - Frontend resources: cpu=50m-200m, memory=128Mi-256Mi
  - Strategic merge patch targeting workclub-frontend deployment

- frontend/src/app/api/health/route.ts
  - Missing health endpoint (declared in base manifest but not implemented)
  - Simple Next.js route handler returning {status: 'ok'}

Resource Limits (Dev vs Base):
- Dev: 50m-200m CPU, 128Mi-256Mi memory (50% of base)
- Base: 100m-500m CPU, 256Mi-512Mi memory

Verification:
- kustomize build succeeds (exit 0)
- All deployments replicas=1
- Lower resource limits applied correctly
- Image tags set to dev
- Frontend /api/health route registered
- Evidence saved to .sisyphus/evidence/task-25-kustomize-dev.yaml (495 lines)

Note: commonLabels deprecated warning (non-blocking), consider using labels in future.
2026-03-03 21:11:18 +01:00
WorkClub Automation
7a2b79af83 infra(docker-compose): add full-stack development environment
Implements Task 22: Docker Compose Full Stack with Hot Reload

Services added:
- dotnet-api: Builds from backend/Dockerfile.dev
  - Port 5000→8080, volume mount for hot reload
  - Development environment with database + Keycloak config
  - Depends on: postgres (healthy), keycloak (healthy)

- nextjs: Builds from frontend/Dockerfile.dev
  - Port 3000, volume mount with node_modules exclusion
  - API URLs, NextAuth, Keycloak config
  - Depends on: dotnet-api

Dependency chain: postgres → keycloak → dotnet-api → nextjs

Features:
- Hot reload enabled via volume mounts with :cached flag (macOS)
- Backend runs migrations + seed on startup (Development mode)
- dotnet watch monitors backend changes
- bun run dev monitors frontend changes
- All services on app-network bridge

Environment variables configured for local development.

Note: Docker build/runtime verification skipped (Docker daemon unavailable).
2026-03-03 21:05:23 +01:00
WorkClub Automation
6124557f11 infra(docker): add Dockerfiles for backend and frontend
Implements Tasks 23 & 24: Backend and Frontend Dockerfiles

Backend Dockerfiles:
- Dockerfile.dev: Development with dotnet watch hot reload
  - Base: sdk:10.0, installs dotnet-ef tool
  - Layer caching: csproj files copied before source
  - Entry: dotnet watch run with --no-restore
- Dockerfile: Production multi-stage build
  - Build stage: sdk:10.0, restore + build + publish
  - Runtime stage: aspnet:10.0-alpine (~110MB)
  - Health check: /health/live endpoint
  - Non-root: USER app (built-in)

Frontend Dockerfiles:
- Dockerfile.dev: Development with Bun hot reload
  - Base: node:22-alpine, installs Bun globally
  - Layer caching: package.json + bun.lock before source
  - Command: bun run dev
- Dockerfile: Production standalone 3-stage build
  - Deps stage: Install with --frozen-lockfile
  - Build stage: bun run build → standalone output
  - Runner stage: node:22-alpine with non-root nextjs user
  - Copies: .next/standalone, .next/static, public
  - Health check: Node.js HTTP GET to port 3000
  - Entry: node server.js (~240MB)

All Dockerfiles use layer caching optimization and security best practices.

Note: Docker build verification skipped (Docker daemon not running).
2026-03-03 20:59:20 +01:00
WorkClub Automation
c29cff3cd8 feat(ui): add login page, club picker, and dashboard
Implements Task 21: Login Page + First-Login Club Picker + Dashboard

New pages:
- Login page: Sign in with Keycloak button, clean centered layout
- Select club page: Club selection cards for multi-club users
- Dashboard: Summary with task/shift counts and quick links

Key features:
- Login delegates to Keycloak via NextAuth signIn('keycloak')
- Club picker shows cards with name + sport type
- Clicking club → setActiveClub() → redirects to /dashboard
- Dashboard shows active club name, open tasks count, upcoming shifts count
- Quick action links to /tasks and /shifts pages
- TanStack Query hooks with proper filters (status: 'Open', future shifts only)

TDD:
- 2 login tests (component export, signIn exists)
- 2 select-club tests (component export, useTenant exists)
- 4 dashboard tests (component export, hooks exist)

Task 21 tests: 8/8 pass. Build succeeds (9 routes registered).

Note: 38 pre-existing tests from Tasks 10,18-20 fail due to Bun+vitest
test infrastructure issues (vi.mocked() not supported, localStorage mock).
This is technical debt to be addressed separately.
2026-03-03 20:44:07 +01:00
WorkClub Automation
817c9ba537 feat(ui): add shift management UI with list, detail, and sign-up
Implements Task 20: Shift Sign-Up UI - List + Detail + Create Pages

New components:
- useShifts hook: TanStack Query hooks (useShifts, useShift, useCreateShift, useSignUpShift, useCancelSignUp)
- Shift list page: Card-based UI (NOT table) with capacity bars and Past badges
- Shift detail page: Full info with sign-up/cancel buttons, member list
- New shift form: Create shifts with title, description, location, times, capacity
- ShiftCard component: Reusable card with capacity Progress bar

Key features:
- Card-based UI pattern (shadcn Card, NOT Table - more visual for schedules)
- Capacity calculation: (currentSignups / capacity) * 100 for Progress bar
- Past shift detection: new Date(startTime) < new Date() → shows 'Past' badge
- Sign-up button visibility: !isPast && !isFull && !isSignedUp
- Cancel button visibility: !isPast && isSignedUp
- Role-based 'New Shift' button: Manager/Admin only
- TanStack Query with automatic cache invalidation on mutations
- Navigation includes Shifts link in sidebar

New shadcn components:
- Progress: Radix UI progress bar with transform-based fill
- Textarea: Styled textarea for shift descriptions

TDD:
- 3 shift card tests (capacity display, full capacity, past shifts)
- 3 shift detail tests (sign-up button, cancel button, mutation calls)

All tests pass (37/37: 31 existing + 6 new). Build succeeds.
2026-03-03 20:22:52 +01:00
WorkClub Automation
c8ae47c0bc feat(ui): add task management UI with list, detail, and create pages
Implements Task 19: Task List + Task Detail + Status Transitions UI

New components:
- useTasks hook: TanStack Query hooks (useTasks, useTask, useCreateTask, useUpdateTask)
- Task list page: shadcn Table with status filter, pagination, status badges
- Task detail page: Full task info with valid status transition buttons
- New task form: Create task with title, description, assigneeId, dueDate

Key features:
- Status transitions match backend logic: Open→Assigned→InProgress→Review→Done
- Review status allows back-transition to InProgress (only bidirectional)
- Only valid next states shown as buttons (VALID_TRANSITIONS map)
- Status badge colors: Open=gray, Assigned=blue, InProgress=yellow, Review=red, Done=green
- TanStack Query with automatic cache invalidation on mutations
- Next.js 15+ async params pattern (use() hook)

TDD:
- 3 task list tests (renders rows, status badges, new task button)
- 3 task detail tests (Open→Assigned, InProgress→Review, Review→Done+InProgress)

All tests pass (31/31). Build succeeds.
2026-03-03 20:12:31 +01:00
WorkClub Automation
46bbac355b feat(ui): add layout, club-switcher, and auth guard
Implements Task 18: App Layout + Club-Switcher + Auth Guard

New components:
- TenantContext: Manages activeClubId state with TanStack Query
- QueryProvider: TanStack Query client wrapper (60s stale time)
- AuthGuard: Auth + tenant redirect logic (unauthenticated → /login)
- ClubSwitcher: shadcn DropdownMenu for switching clubs
- SignOutButton: Simple sign out button
- Protected layout: Sidebar navigation + top bar with ClubSwitcher

Key features:
- Fetches clubs from /api/clubs/me
- Auto-loads activeClubId from localStorage
- Sets X-Tenant-Id cookie on club switch
- Invalidates all queries on club switch
- Redirect logic: unauthenticated → /login, 0 clubs → message, 1 club → auto-select, >1 clubs + no active → /select-club

TDD:
- 6 AuthGuard tests (loading, unauthenticated, 0 clubs, 1 club, multiple clubs, authenticated)
- 3 ClubSwitcher tests (renders current club, lists all clubs, calls setActiveClub on selection)

Dependencies:
- Added @tanstack/react-query

All tests pass (25/25). Build succeeds.
2026-03-03 19:59:14 +01:00
WorkClub Automation
54b893e34e test(frontend): add Playwright E2E test setup
Implement Task 17: Frontend Test Infrastructure - Playwright

Configuration:
- playwright.config.ts: baseURL localhost:3000, Chromium only
- Screenshot on failure, trace on first retry
- Auto-start webServer (bun dev) if not running
- Test directory: ./e2e/

Smoke Test:
- e2e/smoke.spec.ts: Navigate to / and assert page title
- Verifies Next.js app loads successfully

Package Updates:
- Added @playwright/test@^1.58.2
- Added test:e2e script to run Playwright tests
- Chromium browser (v1208) installed

Note: Vitest setup was completed in Task 10
Build: TypeScript checks pass, 1 test discovered
Pattern: Standard Playwright configuration for Next.js
2026-03-03 19:45:06 +01:00
WorkClub Automation
db880b3480 feat(clubs): add Club and Member API endpoints with auto-sync
Implement Task 16: Club + Member API endpoints with MemberSyncService

Services:
- ClubService: GetMyClubsAsync (user's clubs), GetCurrentClubAsync (tenant club)
- MemberService: GetMembersAsync (list), GetMemberByIdAsync, GetCurrentMemberAsync
- MemberSyncService: Auto-creates Member records from JWT on first request

Middleware:
- MemberSyncMiddleware: Runs after auth, calls MemberSyncService

Endpoints:
- GET /api/clubs/me (list user's clubs)
- GET /api/clubs/current (current tenant's club)
- GET /api/members (list members, RLS filtered)
- GET /api/members/{id} (member detail)
- GET /api/members/me (current user's membership)

Tests: 14 integration tests (6 club + 8 member)
- Club filtering by user membership
- Multi-tenant isolation via RLS
- Member auto-sync on first request
- Cross-tenant access blocked
- Role-based authorization

Build: 0 errors, all tests compile
Pattern: TypedResults, RequireAuthorization policies, TDD approach
2026-03-03 19:41:01 +01:00
WorkClub Automation
0ef1d0bbd4 feat(shifts): add Shift CRUD API with sign-up/cancel and capacity management
- ShiftService with 7 methods: list, detail, create, update, delete, signup, cancel
- 5 DTOs: ShiftListDto, ShiftDetailDto, CreateShiftRequest, UpdateShiftRequest, ShiftSignupDto
- Minimal API endpoints: GET /api/shifts, GET /api/shifts/{id}, POST, PUT, DELETE, POST /signup, DELETE /signup
- Capacity validation: sign-up rejected when full → 409 Conflict
- Past shift blocking: cannot sign up for past shifts → 422 Unprocessable
- Duplicate signup prevention: check existing before create → 409 Conflict
- Concurrency: 2-attempt retry loop for last-slot race conditions
- Authorization: POST/PUT (Manager+), DELETE (Admin), signup/cancel (Member+)
- Test infrastructure: Added X-Test-UserId header support for member ID injection
- 13 TDD integration tests: CRUD, sign-up, capacity, past shift, concurrency
- Build: 0 errors (6 BouncyCastle warnings expected)

Task 15 complete. Wave 3: 3/5 tasks done.
2026-03-03 19:30:23 +01:00
WorkClub Automation
8dfe32dc95 docs(plan): mark Task 14 complete 2026-03-03 19:19:27 +01:00
WorkClub Automation
8550dd213a feat(tasks): add Task CRUD API with 5-state workflow
- TaskService with CRUD operations + state machine enforcement
- 5 DTOs: TaskListDto, TaskDetailDto, CreateTaskRequest, UpdateTaskRequest
- Minimal API endpoints: GET /api/tasks, GET /api/tasks/{id}, POST, PATCH, DELETE
- State machine: Open→Assigned→InProgress→Review→Done (invalid transitions → 422)
- Concurrency: DbUpdateConcurrencyException → 409 Conflict
- Authorization: POST (Manager+), DELETE (Admin), GET/PATCH (Member+)
- RLS: Automatic tenant filtering via TenantDbConnectionInterceptor
- 10 TDD integration tests: CRUD, state transitions, concurrency, role enforcement
- Build: 0 errors (6 BouncyCastle warnings expected)

Task 14 complete. Wave 3: 2/5 tasks done.
2026-03-03 19:19:21 +01:00
WorkClub Automation
cff101168c test(rls): add multi-tenant isolation integration tests
- 6 comprehensive RLS tests: complete isolation, no context, insert protection, concurrent requests, cross-tenant spoof, interceptor verification
- Uses Testcontainers PostgreSQL + Dapper for raw SQL validation
- Parallel safety test: 50 concurrent requests with ConcurrentBag
- Build passes: 0 errors (6 expected BouncyCastle warnings)
- Evidence: task-13-rls-isolation.txt (21KB), task-13-concurrent-safety.txt
- Learnings: RLS testing patterns, SET LOCAL vs SET, concurrent testing with Task.WhenAll

Task 13 complete. Wave 3: 1/5 tasks done.
2026-03-03 19:11:01 +01:00
WorkClub Automation
d3f8e329c3 feat(frontend-auth): complete NextAuth.js Keycloak integration with middleware, hooks, and API utility
- Add middleware.ts for route protection (redirects unauthenticated users to /login)
- Add useActiveClub() hook for managing active club context (localStorage + session)
- Add apiClient() fetch wrapper with automatic Authorization + X-Tenant-Id headers
- Configure vitest with jsdom environment and global test setup
- Add comprehensive test coverage: 16/16 tests passing (hooks + API utility)
- Install test dependencies: vitest, @testing-library/react, @vitejs/plugin-react, happy-dom

Task 10 COMPLETE - all acceptance criteria met
2026-03-03 19:01:13 +01:00
WorkClub Automation
4322ec925d docs(plan): mark Tasks 1-9, 11-12 as complete
Wave 1 (Tasks 1-6): COMPLETE
Wave 2 (Tasks 7-12): Tasks 7-9, 11-12 COMPLETE; Task 10 partial (auth config only)
2026-03-03 18:53:12 +01:00
WorkClub Automation
6a9f4d52b2 feat(frontend-auth): add NextAuth.js v5 Keycloak integration (partial - Task 10)
- Install next-auth@5.0.0-beta.30 and @auth/core@0.34.3
- Configure Keycloak OIDC provider with JWT and session callbacks
- Add module augmentation for JWT and Session types (clubs claim support)
- Export auth handlers and configuration

INCOMPLETE: Missing middleware.ts, useActiveClub() hook, API utility, and tests
Will complete in follow-up session resumption
2026-03-03 18:52:44 +01:00
WorkClub Automation
3a82933fd5 fix(backend): simplify Finbuckle namespace imports and register DB interceptors
- Use consolidated Finbuckle.MultiTenant namespace instead of separate imports
- Switch TenantProvider to use untyped IMultiTenantContextAccessor (Finbuckle 9.x pattern)
- Register TenantDbConnectionInterceptor and SaveChangesTenantInterceptor as singletons
- Add interceptors to DbContext configuration for RLS tenant context support
- Update evidence files for Task 7 and Task 8 verification
2026-03-03 18:52:35 +01:00
WorkClub Automation
c9cb629ddb fix(backend): use explicit Finbuckle.MultiTenant namespace imports 2026-03-03 14:32:55 +01:00
WorkClub Automation
eff6fded72 chore(backend): clean up redundant Finbuckle package and add ITenantProvider interface 2026-03-03 14:32:43 +01:00