Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt

Use this file to discover all available pages before exploring further.

Feature: HR-34 Contractor & Contingent Workforce Management
Version: 1.0
Created: 2026-03-25
Status: Pre-Production Review
Owner: HR (Workforce & HRIS)

1. Regulatory References

RegulationCitationHR-34 Control
IRS Worker Classification (20-factor test)IRS Rev. Rul. 87-41; Pub 15-Ahr_contractor_classification_tests table with behavioral_control, financial_control, relationship_type JSONB fields; mandatory rationale text; overall_classification result
1099-NEC Reporting Threshold26 USC §6041A; IRS Form 1099-NEChr_get_contractor_1099_totals RPC aggregates approved time entries; useContractor1099Export hook applies $600 filing threshold
Arizona Independent Contractor (ARS 23-902)ARS §23-902 (worker classification for workers’ comp)Classification test UI captures all IRS factors; results stored with reviewed_by audit trail
Tax ID ProtectionIRS Pub 1281; HIPAA analog for financial PIItax_id_encrypted column; hr.contractor.tax_id.read permission gate; no tax IDs in notification payloads

2. Database Controls

2.1 Classification Documentation

ControlImplementationEvidence
Structured IRS factor testhr_contractor_classification_tests with behavioral_control, financial_control, relationship_type JSONB columnsMigration exists; RLS test: tests/rls/hr/hr-contractor-classification-tests.rls.test.ts
Mandatory rationalerationale TEXT NOT NULL on classification testsSchema constraint; unit test validates non-empty
Audit trailreviewed_by, created_by, updated_by, created_at, updated_at columnsStandard audit columns on all 6 tables
Organization isolationRLS via hr_has_org_access SECURITY DEFINER18 RLS tests across 6 tables

2.2 Financial Data Protection

ControlImplementationEvidence
Tax ID access restrictionhr.contractor.tax_id.read permission keyPermission seeded in pf_module_permissions; gated in UI via useHasPermission
Approved-only 1099 aggregationhr_get_contractor_1099_totals RPC filters approval_status = 'approved'RPC is SECURITY DEFINER; unit test: tests/unit/cores/hr/contractor-1099-export.test.ts
Amount calculation integritycalculateTimeEntryAmount(hours, rate) with roundingUnit test: tests/unit/cores/hr/contractor-workforce-utils.test.ts (5 cases including float rounding)
Notification payload safetyNo tax IDs in pf_notifications.dataCode review: contractorNotifications.ts uses only contractor_id, contract_id, due_date

3. RLS Test Evidence

TableTest FileTestsIsolation Verified
hr_staffing_agenciestests/rls/hr/hr-staffing-agencies.rls.test.ts3✅ Own-org CRUD + cross-org blocked
hr_contractorstests/rls/hr/hr-contractors.rls.test.ts3✅ Own-org CRUD + cross-org blocked
hr_contractor_contractstests/rls/hr/hr-contractor-contracts.rls.test.ts3✅ Own-org CRUD + cross-org blocked
hr_contractor_classification_teststests/rls/hr/hr-contractor-classification-tests.rls.test.ts3✅ Own-org CRUD + cross-org blocked
hr_contractor_time_entriestests/rls/hr/hr-contractor-time-entries.rls.test.ts3✅ Own-org CRUD + cross-org blocked
hr_contractor_credentialstests/rls/hr/hr-contractor-credentials.rls.test.ts3✅ Own-org CRUD + cross-org blocked
Total6 files18All pass

4. Unit & Integration Test Evidence

SuiteFileTestsCoverage
Utility functionstests/unit/cores/hr/contractor-workforce-utils.test.ts17Amount calc, renewal window, expiry, formatters, badges
1099 export logictests/unit/cores/hr/contractor-1099-export.test.ts10Filing threshold ($600), edge cases, RPC coercion
Notification helperstests/unit/cores/hr/contractorNotifications.test.ts10Window logic for renewals and credentials
Integration CRUDtests/integration/hr/contractor-crud.integration.test.ts7Full lifecycle: agency → contractor → contract → time → classification → approval
Total4 files44

5. SECURITY DEFINER Helpers

FunctionPurposeRecursion-Safe
hr_has_org_access(org_id, user_id)Org membership check for RLS✅ Queries pf_user_role_assignments directly
hr_contractor_manager_can_see_contractor(contractor_id, user_id)Department-scoped visibility✅ Joins via non-RLS path
hr_get_contractor_1099_totals(org_id, tax_year)Approved payment aggregation✅ SECURITY DEFINER; service-role or org-access gate

6. Permission Keys

KeyPurposeSeeded
hr.contractor.viewView contractor profiles
hr.contractor.manageCreate/edit/delete contractors
hr.contractor.tax_id.readView encrypted tax IDs
hr.contractor.time.approveApprove/reject time entries
hr.contractor.classifyPerform classification tests
hr.staffing_agency.manageManage staffing agencies

7. Edge Function (Batch Reminders)

FunctionPurposeDeployed
contractor-compliance-remindersCron-triggered batch scan for expiring contracts and credentials
Controls: Uses createNotificationIfNew for 24h deduplication; no tax IDs in payloads; service-role only.

8. Open Items

ItemStatusRisk
tax_id_encrypted actual encryption implementationDeferred to HR-PAY-04 Phase 2Medium — column exists but encryption at-rest TBD
HR-PAY-04 1099-NEC filing automationStub + export hook complete; filing deferredLow — manual export available
Admin guide documentationT-DOC-ADMIN recommended, not MVP-blockingLow

9. Sign-Off

  • Security review: RLS + permission gates verified
  • Compliance review: Classification UI captures IRS factors
  • Tax data review: No tax IDs in notifications or client logs
  • Test evidence: 62 total tests (18 RLS + 44 unit/integration)