AI agent role source of truth: MyProdusen production uses exactly three roles:
SUPERADMIN,LEADER, andEMPLOYEE.ADMIN_HRandSUPERVISORare historical database values only and must not be exposed in production UI or route access.
Highest priority: protect employee data. RBAC is enforced server-side. Frontend hiding is UX, not security.
JWT_SECRET≥ 32 random characters (production aborts otherwise — verified inlib/auth.ts)..envnever committed. Coolify holds all secrets.- Passwords hashed with bcrypt.
- Strict
getProductionJwtSecret()is the single signing helper for sessions and password-reset tokens. - HTTPS terminated by Coolify. Geolocation requires HTTPS by browser policy; do not work around it.
- Cookie-authenticated mutating API requests are protected by an Origin/Referer
guard in root
proxy.tsfor every/api/*mutation, pluslib/core/route-handler.tsfor wrapped handlers; bearer-token API clients remain usable for trusted server-to-server calls. - Baseline HTTP security headers are configured in
next.config.js: CSP,X-Frame-Options: DENY, HSTS in production,Referrer-Policy,Permissions-Policy, COOP, andX-Content-Type-Options: nosniff. - Auth rate limiting fails safe for login/register/password-change by falling back to an in-process limiter if Redis is unavailable.
| Role | Access |
|---|---|
SUPERADMIN |
Full access. Role management, audit log read, system settings, reports, payroll, approvals, employee/team/location/shift management. |
LEADER |
Employee self-service plus assigned-team KPI/team scope only. No team payroll access, no global reports, no Superadmin APIs. |
EMPLOYEE |
Own data only. Submit attendance / leave / corrections, view own KPI/payroll/notifications/profile. |
Inactive users cannot log in. Disabled accounts lose access on the next auth revalidation.
System role controls access only. Operational labels such as HR, Expedition, Driver, or Staff belong in employee division, team, and position, not in new RBAC roles. LEADER is the only production team-lead access role. Public registration always creates inactive EMPLOYEE; only existing authorized Superadmin flows may assign LEADER or SUPERADMIN, with last-Superadmin safety checks.
OWASP API authorization guardrails:
- Non-
SUPERADMINreimbursement claim reads are always scoped to the current user's linked employee record. - Non-
SUPERADMINovertime request reads are always scoped to the current user's linked employee record. - KPI result-by-id reads require
KPI_READor ownership of the result's employee/user record. - Route source-contract tests in
tests/security/api-authorization-hardening.test.tsprevent regression.
Authentication email uses Resend through lib/email.ts.
- Required production env:
RESEND_API_KEYandRESEND_FROM_EMAIL. - Registration and public registration send the
registertemplate. - Forgot password sends a 30-minute reset link using the
forgot-passwordtemplate. - Successful password reset sends the
reset-passwordconfirmation template. - Role changes and account activation send
role-changedandaccount-approvedtemplates where applicable. - If Resend env is missing outside production, email is logged as skipped for developer convenience. Production must configure Resend in Coolify.
- GPS validation runs through
lib/attendance/gps-validation.ts. Frontend decisions are ignored. - Validates lat/lon presence and range, accuracy ≤
GPS_MAX_ACCURACY_METERS, optionalgpsTimestampfreshness ≤GPS_TIMESTAMP_MAX_AGE_SECONDS, work-location existence + active flag. - Server computes Haversine distance vs
WorkLocation.radius. REJECT_OUTSIDE_GEOFENCE=true(default) blocks outside-radius submissions.falseenqueues them asOUTSIDE_GEOFENCEexceptions and notifies SUPERADMIN.- Admin approval flips
check_in_geo_statustoAPPROVED_MANUAL. Rejection flips it toREJECTED. Both notify the affected employee. - Manual attendance adjustment requires Superadmin and a reason ≥ 5 characters.
- Stored under the private persistent volume
/app/uploads/attendance-selfies/.... - Never exposed as a public static folder.
- Served only through authenticated routes:
GET /api/attendances/:id/selfie/check-inGET /api/attendances/:id/selfie/check-out- Legacy:
GET /api/attendance/selfie/[...path](still backward-compatible).
- RBAC: Employee → own only; Leader → own plus assigned team KPI scope; Superadmin → all.
ADMIN_HRandSUPERVISORhistorical values receive no production access. - Path traversal blocked: attendance ID validated by
^[A-Za-z0-9_-]+$, storage path resolver re-checks containment underUPLOAD_DIR. - Stored selfie path strings are sanitised; backslashes, leading slashes,
..segments are rejected outright. - Cache headers:
Cache-Control: no-store, privateplusX-Content-Type-Options: nosniff.
/dashboard/reports/pdfandPOST /api/reports/pdfare Superadmin-only.- PDF responses use
Cache-Control: no-store, no-cache, must-revalidate, private. - Report type, date range, and row caps are validated with
PDF_REPORT_MAX_ROWSandPDF_REPORT_MAX_DATE_RANGE_MONTHS. - Selfie path, URL, and binary fields are stripped from PDF data.
- Every PDF download writes a
DOWNLOAD_PDFaudit log.
Every sensitive action writes to AuditLog with actorUserId, action,
entity, entityId, serialised payload, IP, and user-agent. Current actions:
LOGIN,LOGOUT,LOGIN_FAILED(where feasible).CHECK_IN,CHECK_OUT,CHECK_IN_FAILED,CHECK_OUT_FAILED,CHECK_IN_REJECTED_SELFIE,CHECK_OUT_REJECTED_SELFIE.CHECK_IN_GPS_VALID,CHECK_IN_GPS_PENDING_REVIEW,CHECK_IN_GPS_REJECTED, plus the matching check-out variants.SELFIE_VIEW(only for non-owner views),INVALID_SELFIE_ACCESS.EXPORT(attendance, leave, KPI, employee reports).APPROVE/REJECTfor leave, KPI, attendance exceptions.CREATE/UPDATE/DELETEfor employees, locations, shifts, KPI templates, attendance adjustments.ROLE_CHANGE,USER_ACTIVATE,USER_DEACTIVATE.
Audit logs are read-only for non-superadmins. Retention follows the policy
documented in docs/GO_LIVE_STEPS.md.
Persisted in the Notification table with a best-effort realtime publish on
the myprodusen:realtime channel. Notification failures never block the
originating mutation.
Triggered by:
- Leave approval / rejection.
- KPI approval.
- Pending geo-fence attendance (notifies SUPERADMIN).
- Geo approve / reject (notifies the employee).
- Upload volume
/app/uploadsmust remain private and must not be mapped as public static storage. - Attendance selfies are served only through protected API endpoints with ownership/RBAC checks.
- Payroll endpoints must enforce employee/leader-own access and Superadmin full access server-side.
ADMIN_HRandSUPERVISORmust be denied. - PDF report page and API remain Superadmin-only; non-Superadmin access must be tested after deploy.
- Gamification must stay disabled by default and must not expose private HR data, payroll, attendance, leave, KPI, employee identifiers, document names, upload paths, selfie paths, or rank/score data that can identify another employee without RBAC approval.
- Theme experiments must stay disabled by default and must not weaken auth, RBAC, CSRF, private cache, upload, or protected route controls.
scripts/check-release-gates.mjsblocks enabled gamification flags unlessGAMIFICATION_RELEASE_APPROVED=trueis present.scripts/check-release-gates.mjsblocks theme experiment flags unlessTHEME_RELEASE_APPROVED=trueis present.- Release approval env keys are approval markers only; they do not replace server-side authorization tests.
- Secrets live only in Coolify/password manager: never commit
.env, database dumps, upload archives, Resend keys, JWT secrets, or payroll exports. - Protected API responses for selfies, PDF reports, payroll exports, and health checks must use private/no-store cache where sensitive.
- Production smoke test must verify unauthorized employee-to-employee, legacy-role, and public upload access denial.
-
npm run lintandnpm run testclean before merge. - Login rate limit verified end-to-end (5 attempts / 15 minutes per IP+username).
-
TESTSPRITE_DISABLE_RATE_LIMITS,E2E_DISABLE_RATE_LIMITS,TESTSPRITE_DISABLE_CSRF_ORIGIN, andE2E_DISABLE_CSRF_ORIGINare unset orfalsein production/Coolify. - Cookie-authenticated state-changing routes have Origin/Referer CSRF guard.
- Test-support routes (
/api/test-support/*) and activation-token helpers return 404 in production regardless ofTESTSPRITE_COMPAT_RESPONSE; compat mode is non-production only. - GPS accuracy validation uses
GPS_MAX_ACCURACY_METERSenv (default 100m) instead of hardcoded value. - No PII or secret in logs;
lib/loggerredacts known keys. - Periodic restore drill on staging (quarterly).
Public registration creates an inactive employee-role user and emails a 24-hour
activation link through Resend. The link opens /activate-account?[activation-token],
which posts the token to /api/auth/activate; the backend verifies JWT purpose
account-activation before flipping User.isActive to true.
Superadmin can review registered users at /dashboard/users, see active vs
pending accounts, manually activate/deactivate accounts, and assign access role
(Employee, Leader, Superadmin). Employee placement details
such as division, position, supervisor, shift, and location remain managed in the
employee module.
- PWA service worker must not cache private payroll, attendance, selfie, audit, or report data.
- PWA install prompt must rely on browser
beforeinstallprompt; web apps cannot silently install themselves. - Logout action must call
/api/auth/logoutand clear the httpOnly session cookie before redirecting to/login. - Attendance frontend may show GPS proof, but backend remains the source of truth for GPS accuracy, timestamp age, Haversine distance, geofence decision, selfie validation, and audit logging.
/api/versionis public but must only expose safe operational metadata: app name, status, node env, app version, git commit SHA, and build time.- Never expose secrets, database URLs, email provider keys, passwords, upload paths, selfie paths, or private file names from health/version endpoints.
- Use
/api/healthfor health status and/api/versionfor deploy traceability after Coolify redeploy.
Attendance Wave 2 keeps backend authority for attendance decisions:
- Frontend GPS/selfie status is UX only. Backend validates active employee, default location, active location, default shift, active shift, GPS accuracy, timestamp freshness, Haversine distance, selfie file type/size/signature, and duplicate daily check-in/out.
- Protected selfie endpoints remain authenticated and use ownership/RBAC checks. Employee can access only own selfie, Superadmin can access protected operational selfies.
- Selfie responses use
Cache-Control: no-store, privateandX-Content-Type-Options: nosniff. - Non-owner selfie views and invalid selfie path attempts are audit logged.
- Attendance exception review requires backend endpoint processing and audit logging; rejected review needs a note in UI.
- Leave approval/rejection remains backend-authorized. Rejection requires a human-readable reason and audit log.
- Leave overlap and balance holds are checked server-side; frontend only shows status and guidance.
- KPI result update now rejects edits once a result is approved. Approved KPI changes require a future explicit authorized override flow with reason and audit log.
- KPI template and assignment actions remain Superadmin-only.
- Employee payroll reads remain limited to
/api/payroll/meand the employee attached to the authenticated session. - Payslip download checks ownership for Employee and privileged access for Superadmin.
- Payslip and payroll export responses now send
Cache-Control: no-store, no-cache, must-revalidate, privateandX-Content-Type-Options: nosniff. - Payroll CSV export and payslip download are audit logged.
- PDF reports remain Superadmin-only, private/no-store, and do not export private selfie files.
- Notification list, read, mark-all-read, and delete actions are scoped to the authenticated user ID.
- Realtime events are filtered by target user/scope before delivery.
- Notification list responses now use
Cache-Control: no-store, private. - Audit log API remains Superadmin-only and now returns
Cache-Control: no-store, private. - Audit UI uses no-store fetch and server-side pagination/search.
- Resend remains the only transactional email provider.
- Production email requires
RESEND_API_KEYandRESEND_FROM_EMAIL; missing config fails loudly. - Email delivery attempts are logged in
EmailLogwith template, recipient, subject, status, provider message id, sanitized error, and non-secret metadata. - Tokens, API keys, raw passwords, cookies, and private URLs must not be stored in email metadata.
- Provider API errors are logged server-side only and returned to users through existing safe Indonesian API errors.
- User creation UI no longer ships a default password value; Superadmin must enter a unique initial password.
- Employee API compatibility payload normalization no longer falls back to
Password123!; missing password fails validation. /api/sync/queueno longer returns synthetic success records for attendance or leave. Offline queue operations fail closed until a real service-backed implementation exists.- Production env check now fails if TestSprite/E2E compatibility bypass flags are enabled, including
TESTSPRITE_COMPAT_RESPONSE.
- All shared
successResponse/errorResponseAPI helpers now attachCache-Control: no-store, privateby default for protected JSON payloads. - Global API middleware rejects cross-site cookie-authenticated mutating requests before route handlers run; bearer-token API clients remain supported.
- Forgot-password and reset-password endpoints use the
PASSWORD_RESETrate-limit preset. - Employee document multipart uploads are stored under private
UPLOAD_DIR/employee-documentsand served through authenticated/api/documents/file/:employeeId/:storedNameendpoints with RBAC checks,no-store, andnosniff.
- Protected paths must return
Cache-Control: no-store, private:/api/*,/dashboard/*,/uploads/*, payroll, PDF reports, document files, attendance, and selfie endpoints. - Private responses must never return Cloudflare
cf-cache-status: HIT. - Public static assets may use
public, max-age=31536000, immutablewhen they are logo/static/image/font assets. - Service worker must not register a fetch handler and must not cache
/api/*,/dashboard/*,/uploads/*, selfie, document, payroll, or PDF responses. - Client IP extraction prefers
CF-Connecting-IPonly when Cloudflare trace headers are present, otherwise falls back to the firstX-Forwarded-Forvalue and thenX-Real-IP. - Rate limiting and audit logging use the shared
getClientIp()helper, so Cloudflare proxy traffic still maps to the real client IP when Cloudflare headers are present. - Keep Bot Fight Mode off until login, activation, attendance selfie upload, and PDF export have been tested behind Cloudflare.
- Official geofence source is
WorkLocationin PostgreSQL, not frontend state. - Official coordinate:
3.6009125, 98.6964954, radius100m, nameProdusen Dimsum Medan | TBM GRUP. - Backend loads employee assigned
defaultLocationIdand rejects spoofedworkLocationIdvalues. - Backend Haversine validation uses
GPS_MAX_ACCURACY_METERS,GPS_TIMESTAMP_MAX_AGE_SECONDS, andREJECT_OUTSIDE_GEOFENCE. - Employee with no assigned location cannot check in/out and sees
Lokasi kerja belum tersedia. Hubungi Superadmin. - Selfie remains required through realtime FormData and private upload storage.
- Attendance audit metadata must include employee ID, work location ID, latitude, longitude, accuracy, distance meters, radius meters, and decision where available.
Production roles are now exactly SUPERADMIN, LEADER, and EMPLOYEE. ADMIN_HR and SUPERVISOR remain historical database enum values only and must not appear in production UI, seed accounts, tests, or new route access.
- Full system control: users, employees, roles, teams, leader assignment, employee team assignment, cabang/lokasi kerja, shifts, attendance, KPI, reports/export, payroll if active, and audit logs.
- Can create teams such as Cetak, Gudang, Pengiriman, Packing, Produksi, and Quality Control.
- Can assign one or more active
LEADERusers to teams and assign active employees to teams. - Can view all attendance, KPI production entries, personal KPI, and global reports.
LEADER is also an active employee and must have an employee profile, default work location, and active shift for attendance. If incomplete, UI/API returns: “Anda belum memiliki data karyawan/lokasi kerja/shift. Hubungi Superadmin.” If not assigned to a team, UI/API returns: “Anda belum ditetapkan ke tim. Hubungi Superadmin.”
As self-service employee, LEADER can use GPS + realtime selfie attendance, own attendance history, own leave/cuti, own KPI/kinerja, own personal performance report, own notifications, and own payslip if payroll is active.
As team role, LEADER can view assigned team members only, input daily KPI/production count for assigned employees only, view team KPI summary, and view daily/weekly/monthly team performance reports scoped to assigned team. LEADER cannot view team payroll, edit sensitive employee data, access another leader team, access Superadmin global reports, or input own KPI unless ALLOW_LEADER_SELF_KPI_INPUT=true.
EMPLOYEE can use GPS + realtime selfie attendance, submit leave/cuti, view own KPI/kinerja only, view own attendance history only, view own personal report only, and view own notifications/payslip if active. EMPLOYEE cannot input KPI, see other employee data, or access leader/superadmin pages.
Additive Drizzle migration 0020_leader_role_teams_kpi_production.sql adds enum value LEADER, Team, LeaderAssignment, EmployeeTeamAssignment, and KpiProductionEntry. Migration is non-destructive and keeps historical data.
- Superadmin:
GET/POST /api/teams,POST /api/teams/leader-assignment,POST /api/teams/employee-assignment. - Leader:
GET /api/leader/me,GET /api/leader/team-employees,GET/POST /api/leader/kpi-production. - Self KPI view:
GET /api/kpi/production/me. - Backend enforces role, active user, leader team scope, employee membership, quantity/date validation, self-KPI policy, and no-store API responses.
- Leader dashboard has “Saya / Pribadi” and “Tim Saya”.
- Leader mobile primary nav: Beranda, Absensi, Input KPI, Tim, Akun.
- Leader pages:
/dashboard/leader/kpi-input,/dashboard/leader/team,/dashboard/leader/reports. - Employee KPI page shows production count source “Diinput oleh Leader” and empty state “Belum ada input KPI hari ini.”
- Added credential-only Leader and Employee staging E2E scripts; no passwords or default insecure credentials are stored in code.
- Leader E2E verifies
LEADERaccess to own team APIs and denial from Superadmin-only APIs (/api/users,/api/teams). - Employee E2E verifies denial from Leader APIs (
/api/leader/me,/api/leader/team-employees), Superadmin APIs, and KPI mutation endpoint. - Public live verification passed for unauthenticated dashboard redirect,
/api/reports/pdf401, and secret-safe/api/healthand/api/versionresponses. - Authenticated RBAC verification is pending until real staging
E2E_*credentials and first Leader/team/member assignment exist. - Protected selfie ownership/RBAC and unauthorized selfie checks remain pending for real-device GPS+selfie UAT.
- Public register is employee-only: backend strips any submitted role/team/division/position/location/shift escalation and creates
EMPLOYEEwith existing activation policy. - Only
SUPERADMINcan change role, active status, team/division, position/title, work location, and shift. LEADERremains a self-service employee for GPS+selfie attendance and personal reports, plus team-scoped KPI input for assigned members only.EMPLOYEEremains self-service only and cannot input KPI, view other employees, access Leader pages, or access Superadmin pages.- Role and work identity are separate: role controls access; team/division/position/location/shift control work assignment.
- Team/division examples include Produksi, Kargo, Cetak, Gudang, Pengiriman, Packing, and Quality Control; active data remains configurable by Superadmin.
- Added safe additive migration for position metadata and primary active employee team assignment guard.
- Added/updated production-safe scripts:
seed:leader-teams,setup:uat-leader-flow,verify:uat-leader-flow, andrelease:runtime. release:runtimeis target-container safe and intentionally excludes lint/test/build because production images may not ship dev dependencies.- Remaining production signoff blockers: target-container
release:env, authenticated E2E with real credentials, real-device GPS+selfie attendance, and protected selfie authorization verification.
- Public registration now allows only username, email, and password; role/work identity escalation fields are ignored server-side.
- Public registration always creates inactive
EMPLOYEEper existing activation policy. - Superadmin-only user update API enforces role management server-side, not frontend-only.
- Self-demotion/self-deactivation and last active Superadmin downgrade/deactivation are blocked.
- Leader promotion requires employee profile, active work identity, location, shift, and team assignment.
- Leader assignment removal happens when role is changed back to
EMPLOYEE; employee history remains preserved. - Team KPI input remains restricted to assigned team members only.
- After registration, activation, and first login, the dashboard checks
/api/profile/mewithno-store, privatebehavior. - If phone, address, or
profileCompletedAtis missing, the app shows mandatory modal “Lengkapi Data Pribadi”. - User-editable fields are limited to
phone/ Nomor HP andaddress/ Alamat lengkap. - Users cannot edit role, team/division, position/title, leader status, work location, shift, active status, payroll, or permissions.
- If a self-registered activated user has no employee row yet, saving personal profile creates a minimal employee profile with generated NIP and no work assignment.
- Superadmin-only assignment fields remain role, team/division, position/title, work location, shift, and active status.
- Employee/Leader dashboard shows clean assignment status cards when division, position, location, shift, or Leader team is missing.
- Near-real-time assignment sync uses authenticated profile refetch on dashboard focus and a light 60-second dashboard interval; role/nav updates after refetch/refresh while backend permissions apply immediately.
- Phone/address are private employee data. Owner and Superadmin may access them; Leader team APIs do not expose employee phone/address by default.
- Real-device GPS+selfie, protected selfie authorization, and authenticated live E2E remain required before production signoff.
- Normal attendance check-in/check-out is restricted to
EMPLOYEEandLEADER;SUPERADMINreceives403outside explicit admin correction/report flows. - Profile avatar access uses
/api/profile/avatar/...and is limited to owner user orSUPERADMIN. - Profile avatar responses use
Cache-Control: no-store, privateandX-Content-Type-Options: nosniff. - Profile completion API still rejects self-assignment of role/team/division/position/location/shift/payroll/permissions.
- Avatar upload validates image MIME/signature and stores only the protected route path in employee profile data.
- Public PDF endpoint check: unauthenticated
POST /api/reports/pdfreturns protected response (401), not public200. - CDN verification confirms private dashboard/API/PDF/payroll/attendance routes are not publicly cached.
- Role model remains
SUPERADMIN,LEADER,EMPLOYEEonly for production UI/access. - Superadmin normal selfie attendance remains blocked; Leader/Employee attendance remains self-service only.
- Protected avatar/selfie routes remain no-store/private and require ownership or Superadmin authorization.
Feature flags may hide navigation and entry points, but backend RBAC remains mandatory for every route. Disabled optional modules must not expose private data through main navigation. Core private APIs for attendance, profile/avatar, selfie, payroll, PDF reports, leave, KPI, notifications, and dashboard data must remain authenticated, role-scoped, and no-store/private where applicable.
- Attendance priority flow is GPS + realtime selfie for
EMPLOYEEandLEADER;SUPERADMINdoes not use normal employee selfie clock-in/out. - Official geofence default radius is 150 meters. Backend remains source of truth for distance, GPS accuracy, stale GPS rejection, selfie requirement, and inside/outside decision.
- Attendance late payroll policy is configurable by Superadmin and must not be treated as irreversible legal/business law. Default policy: 1–15 minutes late deducts Rp5.000, 16–30 minutes late deducts Rp10.000, and more than 30 minutes late counts as half-day payroll with pay factor 0.5.
- Shift start uses assigned active shift. Default 08:00 is a fallback reference only for policy defaults; production attendance should require assigned employee shift and show a clear Indonesian error when missing.
- Payroll realtime sync can be ON/OFF globally through company policy and ON/OFF per payroll rule. Payroll rules may target company/division/team/employee, weekly or monthly periods, base salary, attendance policy, KPI target, bonus type, and bonus amount.
- Payroll calculation includes attendance deductions, half-day impact, holiday multiplier, KPI production bonus, and manual adjustments. Approval/reject/paid/unpaid status changes require audit log and user notification.
- Work calendar is configurable by Superadmin. Custom holidays such as Hari Buruh, Hari Pahlawan, Company Holiday, or Custom Libur Pabrik may use paid holiday multiplier; default holiday work multiplier is 2x when enabled by payroll rule.
- KPI Cetak flow: Leader may input production count only for assigned team members, especially Karyawan Cetak. Employee sees only own KPI. KPI production can feed payroll bonus when linked to configured payroll rule.
- Profile photo/avatar is private protected upload data. Users can update own avatar; Superadmin employee list must refresh near-realtime and show protected avatar or initials fallback.
- Production payroll deductions and multipliers must be reviewed and approved by company policy/legal owner before production payroll use.
- Performance score module adds Attendance Score (30%), KPI Score (50%), and Culture & Discipline Score / Penilaian Perilaku Kerja (20%) defaults; configuration must total 100 or return
GAMIFICATION_WEIGHT_INVALID. - New active Employee and Leader start from score 100 and can maintain annual 365-day performance for configurable raise projection tiers.
- Default Platinum projection: score 100 maintained 365 days = +10%, with disclaimer: “Proyeksi ini bersifat estimasi dan dapat berubah sesuai kebijakan perusahaan.”
- Badge service definitions cover Streak 7 Hari, Streak 30 Hari, KPI Perfect Month, Zero Alpha Quarter, Top Performer, and Consistent Gold. Badges are backend-calculated, not fake frontend state.
- Culture & Discipline Score / Penilaian Perilaku Kerja is limited to assigned team members, disallows self-scoring, requires score 0–100 plus notes minimum 10 characters, and queues anomalies for score < 40 or score delta > 30.
- Superadmin controls periods, score weights, raise tiers, anomalies, score overrides with audit reason, reports, and company distribution.
- Theme customization stores sanitized hex colors only, validates contrast, emits safe CSS tokens, audits changes, and resets to default MyProdusen yellow/cream/charcoal/red identity.
- Private performance/theme APIs use no-store responses; payroll/attendance/security actions must not use fake optimistic success.
- UX includes skeleton states, safe progress states (Memvalidasi GPS…, Mengaktifkan kamera…, Menyimpan data…, Menghitung payroll…, Memperbarui skor…), double-submit prevention, and input preservation on error.
- Migration
0026_gamification_constraints_settings.sqlis additive only and hardens gamification constraints/settings. - Run
node scripts/preflight-gamification-0026.mjsbefore production migration; if multiplePerformancePeriodrows areACTIVE, stop and manually audit/resolve without deleting period data. - Gamification config persists in
CompanySetting.GAMIFICATION_CONFIGwith weights 30/50/20, retroactive leader-score days, period type, and raise tiers. - Theme persists in
CompanyThemeSettingwith sanitized hex colors, safe tokens,themeMode,updatedBy, andupdatedAt; invalid contrast returnsTHEME_CONTRAST_INVALID. - Active Employee/Leader score baseline remains 100 for the active period; 365 days at average score 100 projects +10% and remains an estimate, not final payroll commitment.
- Badge service is idempotent and avoids duplicate awards.
scripts/run-gamification-badges.mjsis a manual hook; production worker must call the service with real attendance/KPI/alpha/ranking aggregation before marking automated badge runs complete. - Score override, config/theme changes, exports, leader score submissions, and period state changes require audit trails; Leader scope is own team only.
- Old user-facing "Leader Score" label is now "Culture & Discipline Score" / "Penilaian Perilaku Kerja".
- Legacy
LeaderScoreEntrystorage remains for backward compatibility; no destructive rename. - Formula: Attendance 30% + KPI Produksi 50% + Perilaku Kerja 20%.
GAMIFICATION_WEIGHT_CULTURE=20is primary;GAMIFICATION_WEIGHT_LEADERremains legacy alias fallback.- Superadmin can input/edit Culture & Discipline Score for any Employee/Leader and final score has priority by default (
CULTURE_SCORE_SUPERADMIN_PRIORITY=true). - Leader can input only assigned team members, cannot score self, cannot score outside team, cannot see team salary projection amounts, and cannot override Superadmin final score.
- Advanced subcriteria can evaluate kebersihan, disiplin, ketepatan waktu perilaku, kerapian, kepatuhan SOP, kerja sama tim, tanggung jawab, and optional attitude.
- All submit/update/override actions require audit log:
CULTURE_SCORE_SUBMITTED,CULTURE_SCORE_UPDATED,CULTURE_SCORE_OVERRIDDEN. - Employee sees transparent score breakdown with Perilaku Kerja explanation.
- Preferred API:
/api/performance/culture-score; legacy/api/leader/performance/leader-scoreremains alias.
- Local quality gates passed:
npm run lint,npm run test,npm run build,npm run release:check. - Live route verification passed for
/api/health,/api/version, and unauthenticated PDF protection. - CDN cache verification passed: static assets cacheable; API/dashboard/PDF/attendance/payroll responses no-store/private or non-cacheable.
- Playwright public live smoke found horizontal overflow on
/loginmobile-360. Root cause: auth decorative/background layout could extend document width on deployed build. - Fix applied locally:
.auth-pagenow usesmax-width: 100vw,overflow-x: clip, andbox-sizing: border-box; regression test added intests/ui/auth-overflow-source.test.ts. - Authenticated E2E is BLOCKED because
E2E_SUPERADMIN_EMAIL,E2E_LEADER_EMAIL, andE2E_EMPLOYEE_EMAILare missing. Password env values without matching emails are insufficient. - TestSprite API key is present, but no TestSprite MCP/CLI runner is available in this repo session; TestSprite frontend/backend runs are BLOCKED pending runner/tool access.
- Real-device GPS+selfie UAT is BLOCKED / NOT RUN. See
docs/manual-real-device-uat.md. - GO/NO-GO: NO-GO for production signoff. Public live smoke must pass after redeploy, authenticated E2E credentials must be supplied, TestSprite must run, and real-device UAT must complete.
- Parallel QA agents verified local Playwright public E2E, backend release/RBAC gates, and TestSprite runner availability.
- Local public Playwright passed:
npm run e2e:public=> 20 passed. - Authenticated E2E environment is partial: Superadmin/Employee credentials present in
.env, Leader credentials missing (E2E_LEADER_EMAIL,E2E_LEADER_PASSWORD). Authenticated production signoff remains BLOCKED until all three roles are available and pass. - Authenticated Playwright helpers now forward auth cookies on API-context requests so browser login state and API checks stay aligned.
- Superadmin users-page assertion accepts current UI label
Penggunaplus legacyManajemen User & Aktivasi. - TestSprite remains BLOCKED: local MCP/CLI runner not installed;
@testsprite/testsprite-runnerand@testsprite/testsprite-cliare not available from npm; existing cloud execution previously blocked by billing/credits. - No destructive DB commands were run. Migration/static release checks passed.
- GO/NO-GO: READY FOR REDEPLOY only after commit/push; NOT production signoff until redeploy live public, authenticated roles, TestSprite/owner acceptance, real-device GPS+selfie, prod db deploy, and backup/restore are done.
- Sourced local
.envfor authenticated Playwright probe without printing secrets. - Superadmin and Employee credential variables exist, but live
/api/auth/loginreturned401; credentials are invalid or not provisioned on production. - Leader credential variables are missing:
E2E_LEADER_EMAIL,E2E_LEADER_PASSWORD. - Authenticated E2E remains BLOCKED. Do not mark production signoff until valid production Superadmin/Leader/Employee E2E credentials are supplied and all role suites pass.
- Direct attendance CTA added for Employee and Leader dashboards:
Absensi Hari Ini,Absen Masuk,Absen Pulang,Absensi Selesai. - Attendance page now keeps one selfie+GPS capture flow with
Ambil Selfie, GPS status, work location, distance, radius, inside/outside status, and submit labelsKirim Absen Masuk/Pulang. - Manual correction remains available via
Ajukan Koreksi Manual; backend selfie/GPS/geofence validation remains authoritative. - First-login onboarding now requires
Nama Lengkapminimum 3 chars plus avatar, phone, and address; self-update forbidden fields remain blocked. - Profile page avatar click opens
Perbarui Foto Profilmodal with preview, WebP compression at max 512px/0.8 quality, progress copy, and save. - Superadmin employee list renders protected avatar URLs with alt text, on-focus refetch, and fallback-safe behavior.
- Sidebar brand contrast improved with dark charcoal/brown brand text and readable cream Super Admin badge while preserving yellow/cream MyProdusen style.
- No destructive DB changes.
- Production signoff still requires redeploy, authenticated E2E, real-device GPS+selfie UAT, and protected avatar/selfie live verification.
- Added safe additive
Employee.work_start_date,start_date_set_by, andstart_date_set_atfields; no destructive migration. - Work duration is calculated dynamically in Asia/Jakarta calendar days and shown as
Tanggal mulai kerja/Masa kerja. - Superadmin-only start-date API audits
EMPLOYEE_START_DATE_SET/EMPLOYEE_START_DATE_UPDATED; Employee/Leader cannot edit start date. - Simple payroll calculator documents
gross = baseSalary + kpiBonus + holidayBonus + manualAdditions,deductions = lateDeduction + halfDayDeduction + manualDeductions,netPay = gross - deductions. - Payroll privacy rule: Superadmin may see all; Employee/Leader only own estimate; Leader must not see team salary/payroll.
- Chicken attendance streak service maps PRESENT/HOLIDAY/LEAVE/ABSENT/LATE/HALF_DAY; holiday and approved leave do not break streak.
- Annual raise projection default formula:
projectedRaisePercent = annualScore / 10with max raise 10%; projection is estimate only and requires company approval. - Profile and Superadmin employee list source now surface work duration, payroll estimate copy, chicken streak, score/raise projection copy.
- Executive PDF remains protected/no-store and must include work duration/payroll/performance fields after report template expansion.
- UAT: validate payroll privacy, protected PDF, work duration sync, chicken streak calendar, and raise disclaimer after redeploy.
- Root cause: UAT structural verification checked users/team/shift but did not verify that existing UAT user password hashes still matched
UAT_*_PASSWORD; E2E could skip on missingE2E_*aliases or fail login with 401/429. setup:uat-leader-flownow refreshes password hashes for existing Leader/Employee UAT users whenUAT_*_PASSWORDis provided and verifies bcrypt match without printing passwords.verify:uat-leader-flow/verify:uat-authnow checksleader_login_ready,employee_a_login_ready, andemployee_b_login_readyvia bcrypt compare, still without printing passwords.- RBAC unchanged: Leader remains team-scoped; Employee remains own-scope; no payroll/private data exposure changed.
- If live login returns 429, wait cooldown before authenticated Playwright; 401 means rerun setup and verify auth readiness in target env.
- Employee may read own score, own streak, own badges, own score history, and own raise projection only.
- Leader may read own score/streak and assigned-team attendance/KPI/performance summary only.
- Leader cannot read team salary, payroll amount, payslip, or private payroll export through gamification UI/API.
- Superadmin may read company-wide gamification/performance summaries and review behavior score changes.
- Sensitive gamification endpoints must be authenticated and use
Cache-Control: no-store, private. - Behavior/culture score creation, override, anomaly review, and Superadmin adjustment must be audited.
- Gamification must use real attendance, KPI, and behavior data. Production must not use fake/mock score data.
MVP scope is intentionally limited to operational HRIS flows needed for daily use:
- Absensi selfie + geotag/geofence.
- Payroll/gajian sederhana.
- KPI produksi sync.
- Pengajuan cuti + saldo cuti.
- Role-based dashboard for
SUPERADMIN,LEADER, andEMPLOYEEonly.
Postponed/non-MVP: recruitment, complex BPJS/tax automation, bank disbursement, 360 review, reimbursement, multi-company, enterprise workflow builder, and extra roles such as ADMIN_HR or SUPERVISOR.
Employee/Leader dashboard flow: Clock In/Clock Out → GPS/map validation → distance/radius status → selfie capture → optional note → submit → attendance history refresh. Backend must require authenticated employee profile, assigned active shift, assigned active work location, GPS evidence, selfie evidence, geofence validation, protected selfie storage, and audit-sensitive action logging. Superadmin does not use normal attendance CTA.
Superadmin owns payroll setup, calculation review, period/status control, payslip/report access, and approval/payment state. Employee and Leader can see own payroll/payslip only. Leader cannot see assigned-team salary, payroll amount, payslip, or payroll export. Payroll breakdown should remain simple: base salary, KPI bonus if configured, attendance deduction, holiday multiplier if supported, and final amount.
Leader inputs production KPI only for assigned team members. Leader outside-team input is blocked. Leader self-KPI input stays blocked unless an explicit env/policy allows it. Employee sees own KPI read-only. Superadmin can see all KPI, configure target/rules where available, and filter by division/team/month where available.
Employee and Leader can submit leave request with reason/date/duration, see status, and consume balance only through approved flow. Server blocks overlap and insufficient balance with LEAVE_BALANCE_INSUFFICIENT. Leave balance changes are append-only ledger events. Superadmin approves/rejects and may adjust balance through ledgered workflow.
No fake GPS, fake selfie, fake KPI, fake payroll, or fake leave balance may be marked pass. Real-device attendance and authenticated UAT remain required before production signoff.
MyProdusen supports configurable TBM master data for Administrasi, Produksi, Packing, and BEGE. Superadmin manages divisions, positions, payroll rules, and employee payroll placement from “Struktur Divisi & Gaji”. Defaults are editable seed data, not locked business constants.
Default payroll rules seed:
- Admin Training: Administrasi/Admin monthly training Rp2.000.000 and full Rp2.300.000.
- Produksi Harian: Produksi daily Rp60.000/day.
- Packing Harian: Packing daily Rp60.000/day.
- Produksi Cetak Perempuan: Produksi/Produksi Cetak daily Rp50.000/day.
- Adon Helper Laki-laki: Produksi/Adon Helper daily Rp60.000/day.
- BEGE Default: configurable daily default with custom amount.
Salary privacy: Superadmin can manage and report all salary rules. Employees can read only their own salary rule and payslip. Leaders can see attendance, KPI, score, and production progress only; leaders must not see team salary amounts. Employee-specific custom overrides beat division/position defaults. Training status resolves training salary until training ends, then full salary.
Current frontend UI/UX baseline:
- Design language: Strava-inspired, metric-first, mobile-first.
- Brand accent:
#FFC107yellow. - Fonts: Poppins for UI/headings, JetBrains Mono for stats and numeric values.
- Surfaces: soft gray page bands with white cards.
- Radius: 8px default radius.
- Navigation: white desktop sidebar with yellow active left border; mobile bottom nav with yellow active state.
- Shared primitives restyled globally through
app/globals.css:.btn,.input,.card,.table,.badge,.nav-item,.stat-card,.alert. - Employee Beranda includes Strava-style stat strip: Hadir, Streak, Skor.
Validation status:
npm run lintpassed after UI/UX v4 update.npm run buildpassed after UI/UX v4 update.
When updating this document, keep workflow/security/data rules unchanged and only align frontend descriptions with v4 UI/UX language.