Skip to content

feat(hr): onboarding checklist, 2-level OT to payroll, and probation review (Stage 5B) - #4468

Open
JOY (JOY) wants to merge 1 commit into
mainfrom
agy/4448-hr-onboarding-ot-probation
Open

JOY (JOY) wants to merge 1 commit into
mainfrom
agy/4448-hr-onboarding-ot-probation

Conversation

@JOY

@JOY JOY (JOY) commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4448

Follows Step 0 invariant prep PR #4461 (merged at cad1793e1c845a1320b26f317d91d79e5d57e01d), removing crove_hr.onboarding_submission, crove_hr.overtime_request, and crove_hr.probation_review from PENDING_TABLES in apps/kernel/test/invariant/rls-matrix.db.test.ts as their migrations land here.

What changed for users

  1. Self-service onboarding checklist (/hr/my, /hr/employees):
    • Employees submit contact, citizen ID, tax code, and validated bank confirmation checklist entries on /hr/my (crove_hr.onboarding_submission).
    • Submissions never overwrite employee PII directly; HR owner/admin approves (hr.onboarding.approve) or rejects items in the /hr/employees onboarding queue before updating crove_hr.payroll_employee.
  2. 2-level Overtime (OT) requests to payroll (/hr/my, /hr/employees, /hr/payroll):
    • Employees submit OT requests with work_date, decimal hours (numeric), and day_type (weekday, weekend, holiday).
    • Requests flow through pending_l1 -> pending_final -> approved | rejected | cancelled, enforcing DB triggers and server anti-self-approval checks (crove_hr.is_sole_owner_org sole-owner exception only), plus active department (archived_at IS NULL) and non-viewer manager membership validation on submit.
    • Approved OT requests roll deterministically into draft payroll runs via /hr/payroll (syncOvertime / overtimeFromRequests), using Art. 98 multiplier metadata (150% / 200% / 300%) explicitly labeled status: 'commentary' pending owner-action: the accountant confirms the payroll rule rows and gives worked examples (#2498) #2535.
  3. End-of-probation review with Ludy Cong tac evidence (/hr/employees):
    • Builds deterministic probation evidence from completed Ludy Cong tac (crove_projects) tasks and attendance summaries (crove_hr.probation_review), respecting caller project access and org_app_on(org_id, 'projects') (returning empty/0 when Projects is disabled or inaccessible, without loosening crove_projects RLS).
    • Optional metered Ly coworker action (hr.probation_summary, family 'hr') drafts editable factual De xuat notes only and filters/blocks score or decision directives (AI Law 134/2025/QH15 human oversight). Reviewers explicitly pick pass, extend, or terminate and write/edit the final note.
  4. PDPL erasure, tenant purge (shared-core), and migrations:
    • supabase/migrations/20270315090000_crove_hr_onboarding_ot_probation.sql: schema, indexes, anti-self-approval triggers, column-scoped GRANT UPDATE (no table-wide UPDATE/DELETE), crove_kernel.apply_tenant_rls, and le_scope on all 3 new tables plus crove_hr.overtime_request_employee_name.
    • supabase/migrations/20270315100000_crove_kernel_org_purge_hr_stage5b.sql: updates crove_kernel.org_purge from origin/main (20270315080100, preserving crove_projects.time_entry), deleting the 3 new child HR tables before crove_hr.payroll_employee.
    • Extends hr.payroll.employee.erase (modules/hr/src/employees.ts), packages/kernel/src/personal-data.ts, and packages/kernel/src/offboarding.ts to cancel open OT requests and wipe PII/notes across the new tables.

Acceptance

Verification evidence (head 4bf93a801ed32da633e3b00a5ef20db82a9a4979)

  • Lint, docs, SPDX, migration order: pnpm lint && pnpm docs:check && node tools/ci/spdx-header.mjs && pnpm migration:rebase passed (oxlint: 0 warnings, 0 errors across 4051 files; ui-colors: 662 files OK; docs:check: 250 files OK; spdx: 17 new files OK).
  • Package typechecks: pnpm --filter <pkg> typecheck passed sequentially across @ludy/kernel-contract, @ludy/db, @ludy/agent, @ludy/kernel, @ludy/mod-projects, @ludy/mod-hr, @ludy/kernel-server, and @ludy/app.
  • Unit & UI tests (pnpm vitest run): 13/13 suites, 83/83 tests passed (hr-probation.test.ts, meter.test.ts, hr-probation-ai.test.ts, hr-stage5b-ui.test.tsx, hr-my.test.tsx, hr-stage4b-ui.test.tsx, hr-payroll-preview.test.tsx, manifest-permissions.test.ts, manifest-entities.test.ts, manifest-screens.test.ts, personal-data.test.ts, meetings-translation-isolation.test.ts, org-export-coverage.test.ts).
  • PostgreSQL invariant matrix (CROVE_TEST_ADMIN_URL on ludy-pg17-shared): pnpm test:db apps/kernel/test/invariant/rls-matrix.db.test.ts passed (1615/1615).
  • PostgreSQL integration tests (CROVE_TEST_ADMIN_URL on ludy-pg17-shared, --fileParallelism=false): 10/10 suites, 105/105 tests passed (manifest.db.test.ts, org-purge.db.test.ts, conformance.db.test.ts, check-unions.db.test.ts, personal-data.db.test.ts, hr-stage5b-onboarding-ot-probation.db.test.ts, hr-payroll-run.db.test.ts, hr-self-service-portal.db.test.ts, subject-key-reseal.db.test.ts, sealed-input.db.test.ts).
  • Review results:
    • Fresh-context reviewer (482ceb5d) reviewed 4bf93a801 vs origin/main (dea0c3823): PASS across all 6 checklist criteria.
    • codex review --base origin/main: skipped due to Codex CLI usage quota limit (unavailable until Nov 25, 2026 6:47 PM); supplemented by fresh-context review (482ceb5d) and pending HRM PO security review + Platform PO shared-core review.

Review checklist

  • Correctness: Verified state transitions (pending_l1 -> pending_final -> approved | rejected | cancelled), inactive/viewer manager validation on OT submit, active employee and known-bank checks on onboarding approval, deterministic OT payroll rollup (overtimeFromRequests override preserved on unrelated line edits), and empty/disabled Projects fallback (org_app_on(org_id, 'projects')).
  • Security and authorization: Anti-self-approval DB triggers + server checks, column-scoped GRANT UPDATE without table-wide UPDATE/DELETE, hr.onboarding.approve gated to hr.payroll.run (owner/admin), crove_projects RLS left untouched, Ly probation helper capped to metered hr.probation_summary with untrusted task-title fencing and blocked decision/score outputs.
  • Tenancy: All 3 new tables include org_id, PRIMARY KEY (org_id, id), crove_kernel.apply_tenant_rls, le_scope grants, and cross-tenant/peer-member/viewer isolation verified in rls-matrix.db.test.ts (1615/1615) and hr-stage5b-onboarding-ot-probation.db.test.ts.
  • Money: OT hours stored as numeric in SQL and computed via decimal.js (@crove/l10n-vn money helpers); statutory Art. 98 multiplier figures (150% / 200% / 300%) remain tagged status: 'commentary' pending owner-action: the accountant confirms the payroll rule rows and gives worked examples (#2498) #2535.
  • Performance: Added scoped tenant/status indexes on all 3 new tables and avoided N+1/blocked joins in queue views via crove_hr.overtime_request_employee_name, while keeping UI sub-components modular (hr-onboarding-ot-card.tsx, hr-probation-panel.tsx, hr-stage5b-queues.tsx).
  • Accessibility: Phone inputs, selects, decision radios, and queue action buttons enforce >= 44px (min-h-11) touch targets, explicit labels, and <th scope="col"> table headers (hr-stage5b-ui.test.tsx).

Risk left


📌 TL;DR

This PR introduces the frontend components for the HR self-service onboarding checklist, 2-level overtime (OT) request workflow, and end-of-probation review panel. It also adds the corresponding admin/owner review queues and English localization strings to support these new HR features.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/app/src/components/hr-onboarding-ot-card.tsx Adds HrSelfOnboardingCard for employees to submit checklist confirmations and profile updates, and HrSelfOvertimeCard for submitting OT requests and managing L1 approvals for team members.
apps/app/src/components/hr-probation-panel.tsx Adds HrProbationPanel allowing managers to review employee performance facts (tasks, attendance), generate AI draft notes, and submit probation decisions (pass/extend/terminate).
apps/app/src/components/hr-stage5b-queues.tsx Adds HrOnboardingReviewQueue and HrOvertimeReviewQueue for admins/owners to review, approve, or reject employee submissions with optional decision notes.
apps/app/src/i18n/messages/en.ts Adds English translation keys for the new onboarding, overtime, and probation UI elements, including status labels, form fields, and action buttons.

📊 Architectural Flow

flowchart TD
    subgraph Employee_Self_Service
        A[HrSelfOnboardingCard] -->|Submit| B[hr.self.onboarding.submit]
        C[HrSelfOvertimeCard] -->|Submit| D[hr.self.overtime.submit]
        C -->|Approve L1| E[hr.overtimeRequests.approveL1]
    end

    subgraph Manager_Review
        F[HrProbationPanel] -->|Preview Facts| G[hr.probation.preview]
        F -->|Draft AI Note| H[hr.probation.draftSummary]
        F -->|Decide| I[hr.probation.decide]
    end

    subgraph Admin_Queue
        J[HrOnboardingReviewQueue] -->|Approve/Reject| K[hr.onboarding.approve/reject]
        L[HrOvertimeReviewQueue] -->|Approve L1/Final| M[hr.overtimeRequests.approveL1/approveFinal]
        L -->|Reject| N[hr.overtimeRequests.reject]
    end

    B --> O[Backend API]
    D --> O
    E --> O
    G --> O
    H --> O
    I --> O
    K --> O
    M --> O
    N --> O
Loading

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Nov 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ludy Ready Ready Preview Nov 22, 2026 4:19pm UTC
ludy-app Ready Ready Preview Nov 22, 2026 4:19pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a6cb86b-a3b2-4b36-aace-7d607fa91afd
Commits

Reviewing files that changed from the base of the PR and between dea0c38 and 4bf93a8.

Files ignored due to path filters: 1

  • packages/db/src/generated/database.ts is excluded by !**/generated/**
Files selected for processing: 49

  • apps/app/src/components/hr-onboarding-ot-card.tsx
  • apps/app/src/components/hr-probation-panel.tsx
  • apps/app/src/components/hr-stage5b-queues.tsx
  • apps/app/src/i18n/messages/en.ts
  • apps/app/src/i18n/messages/vi.ts
  • apps/app/src/routes/hr-employees.tsx
  • apps/app/src/routes/hr-my.tsx
  • apps/app/src/routes/hr-payroll.tsx
  • apps/app/test/hr-stage5b-ui.test.tsx
  • apps/kernel/src/conversations-ai.ts
  • apps/kernel/src/hr-probation-ai.ts
  • apps/kernel/src/kernel.ts
  • apps/kernel/src/rpc.ts
  • apps/kernel/test/hr-payroll-run.db.test.ts
  • apps/kernel/test/hr-probation-ai.test.ts
  • apps/kernel/test/hr-stage5b-onboarding-ot-probation.db.test.ts
  • apps/kernel/test/invariant/rls-matrix.db.test.ts
  • apps/kernel/test/manifest-permissions.test.ts
  • apps/kernel/test/meetings-translation-isolation.test.ts
  • apps/kernel/test/personal-data.test.ts
  • docs/runbooks/org-offboarding.md
  • modules/hr/src/employees.ts
  • modules/hr/src/index.ts
  • modules/hr/src/leave-requests.ts
  • modules/hr/src/manifest.ts
  • modules/hr/src/onboarding.ts
  • modules/hr/src/overtime.ts
  • modules/hr/src/payroll-run.ts
  • modules/hr/src/probation.ts
  • modules/projects/src/index.ts
  • modules/projects/src/projects.ts
  • packages/agent/src/hr-probation.ts
  • packages/agent/src/inbox.ts
  • packages/agent/src/index.ts
  • packages/agent/src/meter.ts
  • packages/agent/src/recruiting-coworker.ts
  • packages/agent/test/hr-probation.test.ts
  • packages/db/src/schema.ts
  • packages/db/test/check-unions.db.test.ts
  • packages/kernel-contract/src/contract.ts
  • packages/kernel-contract/src/hr-onboarding.ts
  • packages/kernel-contract/src/hr-overtime.ts
  • packages/kernel-contract/src/hr-payroll.ts
  • packages/kernel-contract/src/hr-probation.ts
  • packages/kernel-contract/src/index.ts
  • packages/kernel/src/offboarding.ts
  • packages/kernel/src/personal-data.ts
  • supabase/migrations/20270315090000_crove_hr_onboarding_ot_probation.sql
  • supabase/migrations/20270315100000_crove_kernel_org_purge_hr_stage5b.sql
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@JOY JOY (JOY) added line:hrm HRM (Ludy Nhân sự) shared-core Needs the Platform PO's shared-core review labels Nov 22, 2026
@JOY

Copy link
Copy Markdown
Contributor Author

Request: Shared-core review (Platform PO) for head 4bf93a8 modifying crove_kernel.org_purge in supabase/migrations/20270315100000_crove_kernel_org_purge_hr_stage5b.sql.

dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (50 eligible files · 405,111 chars · 3 model call(s) · 14 PR unit(s))

Whole diff with bounded context at base dea0c38 / head 4bf93a8.

✅ No verified defects

3 possible issue(s) could not be grounded in or verified against the snapshot source, so they are not published.

Context investigation was bounded to the explicitly requested snapshot paths.

This branch was successfully deployed

1 active deployment
Preview – ludy — 4bf93a80 Deployed Nov 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

line:hrm HRM (Ludy Nhân sự) shared-core Needs the Platform PO's shared-core review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hr: self-service onboarding checklist, 2-level overtime (OT) requests to payroll, and end-of-probation review with Projects evidence (Stage 5B)

1 participant