Skip to content

test(invariant): pre-register HR Stage 5B tables in RLS matrix - #4461

Merged
JOY (JOY) merged 1 commit into
mainfrom
agy/4448-step0-rls-matrix
Nov 22, 2026
Merged

JOY (JOY) merged 1 commit into
mainfrom
agy/4448-step0-rls-matrix

Conversation

@JOY

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

Copy link
Copy Markdown
Contributor

Refs #4448

Step 0 of 2 invariant preparation PR for HR Stage 5B (#4448).

Summary

Pre-registers the three upcoming Stage 5B tenant tables in apps/kernel/test/invariant/rls-matrix.db.test.ts (PENDING_TABLES, MEMBER_VY_READS, AUTHOR_ONLY, and ROW_FACTORIES) so CI's Invariant suite (from base) accepts the Step 1 feature migration PR once this lands on main:

  • crove_hr.onboarding_submission
  • crove_hr.overtime_request
  • crove_hr.probation_review

PENDING_TABLES entries will be removed in Step 1 (or immediately after Step 1 lands) alongside the actual SQL migrations.

Acceptance

  • What changes: Only apps/kernel/test/invariant/rls-matrix.db.test.ts is modified (+46 lines). No runtime code, schema, or production behavior changes.
  • Evidence:
    • pnpm --filter @ludy/kernel-server typecheck: exited 0 cleanly after final edit.
    • CROVE_TEST_ADMIN_URL=... pnpm test:db apps/kernel/test/invariant/rls-matrix.db.test.ts: 1589/1589 passed in this branch, and also verified 1610/1610 passed locally against the draft Stage 5B migration before extracting Step 0.
  • Review results:
    • Fresh-context reviewer (research): PASS (0 blocking findings; 1 operational note to rebase onto origin/main before merge and remove PENDING_TABLES entries in Step 1).
    • codex review -c model_reasoning_effort=high --base origin/main: skipped due to Codex usage quota exhaustion (resets Nov 25th, 2026); HRM PO independent security review applies per protected-path rules.
  • Checklist:
    • Correctness: PASS. Strictly sorted entries across PENDING_TABLES, MEMBER_VY_READS, AUTHOR_ONLY, and ROW_FACTORIES; RowFactory shapes satisfy Record<string, string | number> and planned PostgreSQL CHECK/trigger guards.
    • Security and authorization: PASS. All three tables carry AUTHOR_ONLY = 'false' (system context blocked) and MEMBER_VY_READS = () => 'false' (agent context blocked), matching crove_hr.leave_request and is for owners and admins only for unlinked members and viewers.
    • Tenancy: PASS. Factories populate org_id via payroll_employee setup rows for cross-org and le_scope enforcement.
    • Money: Not applicable. No monetary columns changed (overtime_request.hours uses decimal string '2').
    • Performance: Not applicable. Test factory preparation only; no runtime queries or schema indexes altered.
    • Accessibility: Not applicable. No UI changes.
  • Residual risk: None on main (tables stay skipped via PENDING_TABLES until Step 1 merges). Protected path (apps/kernel/test/invariant/rls-matrix.db.test.ts) awaits HRM PO independent security review and acceptance.

📌 TL;DR

This PR extends the Row-Level Security (RLS) invariant test matrix to cover three new HR tables (onboarding_submission, overtime_request, and probation_review), ensuring that access controls correctly restrict visibility to authorized roles (owners, admins, and linked employees) while blocking system and agent contexts.

🎯 Type of Change

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

🔍 Changes Walkthrough

File Summary of Changes
apps/kernel/test/invariant/rls-matrix.db.test.ts 1. Pending Tables: Added the three new HR tables to the PENDING_TABLES set, indicating they are now subject to RLS verification.
2. Access Control Maps:
- Added entries to MEMBER_VY_READS to verify that member-level views return false (no access) for these HR tables.
- Added entries to AUTHOR_ONLY to enforce that only owners/admins have read access (returning false for other roles).
3. Row Factories: Implemented ROW_FACTORIES for the new tables to generate valid test data:
- onboarding_submission: Creates a linked employee and a pending submission.
- overtime_request: Creates a linked employee and an overtime request with specific date/hour constraints.
- probation_review: Creates a linked employee and a probation review with a defined period and decision.

📊 Architectural Flow

flowchart TD
    subgraph Test_Infrastructure
        A[RLS Matrix Test] --> B[Load Row Factories]
        B --> C{Table Type}
    end

    subgraph New_HR_Tables
        C -->|onboarding_submission| D[Create Employee + Submission]
        C -->|overtime_request| E[Create Employee + Overtime Req]
        C -->|probation_review| F[Create Employee + Probation Review]
    end

    subgraph Access_Verification
        D --> G[Verify MEMBER_VY_READS = false]
        E --> G
        F --> G
        G --> H[Verify AUTHOR_ONLY = false for non-owners]
        H --> I[Assert RLS Policies Enforced]
    end
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.

2 Skipped Deployments
Project Deployment Actions Updated
ludy Skipped Skipped Nov 22, 2026 3:14pm UTC
ludy-app Skipped Skipped Nov 22, 2026 3:14pm 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 3 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: e1d9d5e8-e0e6-4ace-a177-73fe4372d3bd
Commits

Reviewing files that changed from the base of the PR and between 0b66313 and 320e85e.

Files selected for processing: 1

  • apps/kernel/test/invariant/rls-matrix.db.test.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 (1 eligible files · 6,248 chars · 1 model call(s) · 1 PR unit(s))

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

✅ CLEAN_PASS: Complete diff reviewed

@JOY JOY (JOY) added the line:hrm HRM (Ludy Nhân sự) label Nov 22, 2026
@JOY
JOY (JOY) force-pushed the agy/4448-step0-rls-matrix branch from de0f232 to 320e85e Compare November 22, 2026 15:14
@vercel
vercel Bot temporarily deployed to Preview – ludy November 22, 2026 15:14 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 (1 eligible files · 6,250 chars · 2 model call(s) · 1 PR unit(s))

Whole diff with bounded context at base 0b66313 / head 320e85e.

✅ CLEAN_PASS: Complete diff reviewed

@JOY

Copy link
Copy Markdown
Contributor Author

Security review (HRM PO)

Independent protected-path security review completed by fresh-context flagship reviewer (42ba9402-8b09-4a08-8485-7aa855cd, Model: "inherit") on rebased head 320e85ea6612bc482a364ebe653c1479a76f72a8 (apps/kernel/test/invariant/rls-matrix.db.test.ts — non-shared-core two-step pending registration for line:hrm tables per docs/product-owner-config.md).

  • Verdict: PASS (0 blocking findings)
  • Scope verified: Only apps/kernel/test/invariant/rls-matrix.db.test.ts changed (+46, 0 deletions); crove_hr.attendance_log and crove_hr.attendance_qr_config from PR #4458 remain intact alongside sorted entries for crove_hr.onboarding_submission, crove_hr.overtime_request, and crove_hr.probation_review across PENDING_TABLES, MEMBER_VY_READS, AUTHOR_ONLY, and ROW_FACTORIES.
  • Six-item checklist: Correctness PASS, Security & Authorization PASS (AUTHOR_ONLY = 'false', MEMBER_VY_READS = () => 'false'), Tenancy PASS (org_id + payroll_employee isolation), Money N/A, Performance N/A, Accessibility N/A.

@JOY

Copy link
Copy Markdown
Contributor Author

PO acceptance: merge at 320e85e

Verified clean rebased head 320e85ea6612bc482a364ebe653c1479a76f72a8: 34/34 CI checks passed, mergeStateStatus: CLEAN, 0 unresolved review threads, line:hrm label attached, and HRM PO independent security review (https://github.com/DOS/Ludy/pull/4461#issuecomment-7081526138) passed with 0 blocking findings.

This branch was previously deployed

1 inactive deployment
Preview – ludy — 320e85ea 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.

1 participant