Skip to content

feat(hr): surface HR lifecycle and leave alerts on Vy Today feed (#4444) - #4459

Merged
JOY (JOY) merged 1 commit into
mainfrom
agy/4444-hr-today-alerts
Nov 22, 2026
Merged

JOY (JOY) merged 1 commit into
mainfrom
agy/4444-hr-today-alerts

Conversation

@JOY

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

Copy link
Copy Markdown
Contributor

Closes #4444

What

Wire the hr module into Vy's Home (Hôm nay / Today) feed (Stage 5A), attributed to Ly (todayCoworkerKey('hr') === 'finance'), with zero AI cost, zero DB/audit writes, and zero employee PII in parameters:

  • Contract & Kernel wiring: Added 'hr' to TODAY_APPS (packages/kernel-contract/src/today.ts), zHrTodayAsk (packages/kernel-contract/src/hr.ts), and 'hr.today' to TODAY_READS (packages/kernel/src/today.ts).
  • Read-only deterministic query (modules/hr/src/today.ts, exported via modules/hr/src/index.ts):
    • Rejects or fails closed ([]) when actor.type !== 'user', role === 'viewer', or 'hr' is disabled/inactive on crove_kernel.tenant (apps_off, readable under both crove_app and crove_tenant).
    • owner / admin: aggregates alerts across active non-erased staff for probation ending within 7 days (hr.probationEnding, /hr/employees), fixed-term contracts ending within 30 days or already expired while active (hr.contractsExpiring / hr.contractsExpired, /hr/employees), foreign work permits ending within 60 days or expired via workPermitAlertsFor (hr.workPermitsExpiring / hr.workPermitsExpired, /hr/employees), semi-annual 01/PLI labor fluctuation filing windows due June 5 (YYYY-H1) and December 5 (YYYY) when non-erased labor exists in the reporting year (hr.laborReport01Pli, /hr/declarations), and total waiting leave approvals (pending_l1 + pending_final, hr.leaveApprovalsPending, /hr/employees).
    • Active L1 department manager (member with archived_at IS NULL AND manager_user_id = actor.userId, whether linked or unlinked to payroll_employee): sees only the count of pending_l1 leave requests in their managed active department(s), excluding their own linked employee requests (NOT crove_hr.is_self_employee) and erased employees (crove_hr.leave_request_employee_name IS NOT NULL), using hr.deptLeave linking to /hr/my.
    • Non-manager member and viewer: returns [].
  • UI copy, command labels, & tests (apps/app/src/i18n/messages/en.ts, vi.ts, apps/app/test/hr-today-copy.test.tsx, modules/hr/test/hr-today.db.test.ts, packages/kernel-contract/test/today.test.ts, apps/kernel/test/today.test.ts): Added today.items.hr.* messages, commands.hr.today Vietnamese/English labels, and full unit + PostgreSQL 17 integration coverage.

Tests

  • Rebased onto origin/main (e626e250e):
    • pnpm vitest run --project unit packages/kernel-contract/test/today.test.ts apps/kernel/test/today.test.ts apps/kernel/test/command-labels.test.ts apps/app/test/hr-today-copy.test.tsx apps/app/test/i18n.test.ts: passed (5 files, 48 tests).
    • node tools/ci/spdx-header.mjs origin/main: passed (spdx header OK: 3 new source file(s) checked).
  • On identical file contents right before rebase onto feat(sign,agent): add Decree 337/2025 HR contract legal notice and permission-scoped Contract Vault Q&A (#4439) #4456:
    • pnpm --filter @ludy/mod-hr typecheck, pnpm --filter @ludy/app typecheck, pnpm --filter @ludy/kernel-server typecheck, pnpm exec oxlint --deny-warnings <11 changed files>: passed.
    • pnpm vitest run --project unit packages/kernel-contract/test/today.test.ts apps/kernel/test/today.test.ts apps/kernel/test/command-labels.test.ts apps/app/test/hr-today-copy.test.tsx apps/app/test/i18n.test.ts apps/app/test/i18n-no-env-names.test.ts apps/kernel/test/invariant/write-path.test.ts: passed (7 files, 64 tests).
    • CROVE_TEST_ADMIN_URL=postgresql://postgres:postgres@127.0.0.1:55432/postgres pnpm vitest run --project db modules/hr/test/hr-today.db.test.ts: passed (3/3 tests on PG 17).
  • Full GitHub Actions CI runs on PR head 9ba72c8d3.

Acceptance

  • User-visible change: On Vy's Home (Hôm nay / Today) feed, owners and admins see HR compliance and approval alerts under Ly linking directly to /hr/employees and /hr/declarations, while active L1 department managers (member) see only their own department's pending L1 leave approval count linking to /hr/my. Non-manager members and viewers see no HR alerts.
  • Evidence per acceptance item:
    • TODAY_APPS includes 'hr' (todayCoworkerKey('hr') === 'finance') and TODAY_READS includes 'hr.today', verified by packages/kernel-contract/test/today.test.ts, apps/kernel/test/today.test.ts, apps/kernel/test/command-labels.test.ts, and hr-today.db.test.ts (kernel.today returns failed: 0, dropped: 0).
    • Owner/admin notice boundaries (<= 7d probation, <= 30d fixed-term contract + expired active, <= 60d foreign work permit + expired, 01/PLI June 5 & December 5 windows with zero-labor suppression, pending_l1 + pending_final), malformed employment row resilience, ended/erased exclusions, L1 manager scoping (linked and unlinked, excluding self-requests, other departments, archived departments, and pending_final), le_scope, cross-org isolation, MODULE_OFF gating (Runtime + direct crove_tenant execution), zero PII in params, and zero DB/audit writes verified in modules/hr/test/hr-today.db.test.ts.
    • Home copy keys, ICU pluralization, Ly attribution, and /o/<slug>/hr/* link rendering verified in apps/app/test/hr-today-copy.test.tsx and apps/app/test/i18n.test.ts.
  • Review results:
    • Fresh-context research subagent reviewer checked the implementation against #4444 and all 6 checklist dimensions: 0 blocking findings, 4 non-blocking notes (3 applied: explicit pe.org_id filter, malformed historical employment row DB test, clearer Vietnamese workPermitsExpired phrasing; subsequently added missing commands.hr.today labels and renamed leaveApprovalsL1Pending -> deptLeave via hrTitle helper to resolve gitleaks false positive).
    • codex review -c model_reasoning_effort=high --base origin/main unavailable: hit OpenAI Codex usage limit (ERROR: You've hit your usage limit).
  • 6-item review checklist:
    • Correctness: verified exact notice windows (<= 7d, <= 30d, <= 60d, 01/PLI), contract_type = 'fixed_term' scoping, erased_at IS NULL & status = 'active' filtering, and safe skip on malformed legacy employment bounds.
    • Security and authorization: access: ALL with immediate [] for non-user/viewer/non-manager member, crove_kernel.tenant (status/apps_off) fail-closed gate compatible with both crove_app and crove_tenant, omitted sensitive: true (allowing kernel.today invocation) with zero PII or salary columns queried/returned, zero LLM calls, and zero writes.
    • Tenancy: every query filters org_id = ctx.orgId under PostgreSQL RLS (tenant_isolation, le_scope, hr_leave_request_select), and L1 manager scoping uses archived_at IS NULL, NOT crove_hr.is_self_employee, and crove_hr.leave_request_employee_name IS NOT NULL without widening payroll_employee member access.
    • Money: not applicable (hr.today selects zero wage columns and emits no monetary amounts or currencies).
    • Performance: bounded 0 to 5 reads per call (DISTINCT ON (pe.employee_id) skipped when zero active staff; 01/PLI ended check LIMIT 1 skipped when active staff exist), zero N+1 queries.
    • Accessibility: renders through existing TodayList semantics (<a href="/o/<slug>/hr/...">) with verified vi/en ICU copy, zero forbidden coworker names, and zero em/en dashes.
  • Residual risk: Pending full GitHub Actions CI run across all packages and migration/e2e jobs on the final PR head 9ba72c8d3.

Release note (vi): Nhân sự nay xuất hiện trên màn hình Hôm nay của Vy (do Ly phụ trách): chủ doanh nghiệp và quản trị viên thấy cảnh báo thử việc sắp kết thúc, hợp đồng xác định thời hạn, giấy phép lao động nước ngoài, kỳ nộp mẫu 01/PLI và đơn nghỉ phép chờ duyệt; trưởng bộ phận thấy số đơn nghỉ phép của bộ phận mình cần duyệt cấp 1.

@JOY JOY (JOY) added the line:hrm HRM (Ludy Nhân sự) label Nov 22, 2026

@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-app Ready Ready Preview Nov 22, 2026 2:51pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
ludy Skipped Skipped Nov 22, 2026 2:51pm 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 26 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: d42c4e5e-41d6-4f86-b2a9-8565cab0eba3
Commits

Reviewing files that changed from the base of the PR and between e626e25 and 9ba72c8.

Files selected for processing: 11

  • apps/app/src/i18n/messages/en.ts
  • apps/app/src/i18n/messages/vi.ts
  • apps/app/test/hr-today-copy.test.tsx
  • apps/kernel/test/today.test.ts
  • modules/hr/src/index.ts
  • modules/hr/src/today.ts
  • modules/hr/test/hr-today.db.test.ts
  • packages/kernel-contract/src/hr.ts
  • packages/kernel-contract/src/today.ts
  • packages/kernel-contract/test/today.test.ts
  • packages/kernel/src/today.ts
  • 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

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 (11 eligible files · 69,371 chars · 1 model call(s) · 3 PR unit(s))

Whole diff with bounded context at base 795d362 / head 04c18db.

✅ CLEAN_PASS: Complete diff reviewed

@JOY
JOY (JOY) force-pushed the agy/4444-hr-today-alerts branch from 04c18db to 9ba72c8 Compare November 22, 2026 14:51
@vercel
vercel Bot temporarily deployed to Preview – ludy November 22, 2026 14:51 Inactive
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 (11 eligible files · 69,982 chars · 2 model call(s) · 3 PR unit(s))

Whole diff with bounded context at base e626e25 / head 9ba72c8.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

@JOY

Copy link
Copy Markdown
Contributor Author

PO acceptance: merge at 9ba72c8

Verified clean head 9ba72c8d38325aa213bdfba94ece884c67f53bb6: all CI checks passed, mergeStateStatus: CLEAN, 0 unresolved review threads, no protected or shared-core paths modified (tools/ci/protected-paths.mjs classify returned empty), and ## Acceptance with the 6-item review checklist verified complete (Codex CLI limit noted per AGENTS.md).

@JOY
JOY (JOY) merged commit bb87338 into main Nov 22, 2026
35 checks passed
@JOY
JOY (JOY) deleted the agy/4444-hr-today-alerts branch November 22, 2026 15:21

This branch was previously deployed

1 inactive deployment
Preview – ludy — 9ba72c8d 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ự)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hr: surface HR lifecycle and leave approval alerts on Vy Home (Today feed) (Stage 5A)

1 participant