Decoupling AI Recruiting and HR Operations: Signed HMAC Webhooks, pgvector Policy RAG, and PII Scrubbing
Architectural case study on decoupling AI Recruiter and AI HR Platform across candidate-to-employee onboarding via signed HMAC-SHA256 webhooks, pre-LLM PII scrubbing, Celery Beat leave accruals, and active JWT revocation.
HR and talent acquisition share a single pivotal handoff—the moment a candidate signs an offer—yet everything before and after that event belongs to fundamentally different security zones. Combining high-volume candidate scraping and outbound recruiting email pipelines into the same database as active employee leave accruals, compensation metadata, and performance reviews creates unnecessary coupling and elevates breach blast radius.
That is why AI Recruiter and AI HR Operations Platform were engineered as independent services connected strictly across a verified, idempotent event boundary.
The Signed Offer-Accepted Webhook Boundary#
When an opportunity progresses through AI Recruiter's 18-stage recruiting pipeline (including its database-enforced human approval gate for Gmail outreach) and triggers `candidate.offer_accepted`, it dispatches an event to AI HR Platform signed with HMAC-SHA256 and a delivery timestamp:
def verify_signed_handoff(raw_body: bytes, signature_header: str, secret: bytes) -> bool:
expected = hmac.new(secret, raw_body, hashlib.sha256).hexdigest()
provided = signature_header.removeprefix("sha256=").strip()
return hmac.compare_digest(expected, provided)On receipt, the HR microservice validates the signature with `hmac.compare_digest`, verifies event uniqueness so network retries cannot double-create staff accounts (a pattern teams can test locally with tools like Webhook Reliability Kit), and provisions onboarding tasks automatically.
Policy Enforcement Q&A with pgvector RAG and Pre-LLM PII Scrubbing#
Employees routinely paste sensitive personal details into chat boxes when asking about parental leave, expense reimbursements, or compliance SOPs. Routing those raw prompts to external SaaS chatbots creates avoidable compliance exposure. In the HR microservice, employee handbooks and SOPs are chunked and indexed into PostgreSQL 16 `pgvector`, while a pre-inference PII scrubber strips SSNs, personal contact details, and employee IDs prior to generation.
By defaulting to self-hosted Ollama inference (`Llama 3.1 8B`, `Qwen 2.5 7B`, and `nomic-embed-text`), policy answers cite specific handbook sections without transmitting employee questions off-premises.
Asynchronous Leave Accruals and Anti-Bias OKR Synthesis#
Operational reliability in HR depends heavily on background scheduling and clear auditability:
- Celery Beat Accrual Scheduler: Periodically recalculates PTO, sick, parental, and bereavement leave balances with rollover caps, paired with live team calendar conflict checks during manager approval.
- 360-Degree Reviews with Anti-Bias Guardrails: Gathers self, peer, manager, and direct-report feedback alongside OKR completion telemetry while prompting reviewers toward observable behavioral evidence.
- Multi-Tenant RBAC & Active JWT Revocation: Separates `SUPER_ADMIN`, `HR_ADMIN`, `PEOPLE_MANAGER`, and `EMPLOYEE` scopes, backed by active token revocation on logout so compromised sessions invalidate immediately.
Designing cleanly bounded internal microservices or connecting legacy systems with signed event contracts? Review my Software Architecture and AI Engineering practices, or book a consultation.
Production Case Studies & Capabilities
Explore how these engineering patterns are deployed in production systems and available through client engagements.
AI HR Operations Platform
A production-ready Python (FastAPI) and React HR operations microservice with pgvector policy RAG, multi-tier leave accrual scheduling, 360-degree OKR reviews, pre-LLM PII scrubbing, and signed HMAC-SHA256 webhook handoff from AI Recruiter.
AI Recruiter
A production-grade Python (FastAPI) and React platform providing provider-neutral LLM opportunity evaluation, DNS-verified recruiter discovery, and database-enforced human-in-the-loop outreach.
Software Architecture & System Design
Fast-moving teams frequently accrue hidden architectural liabilities: tangled domain logic, unmaintainable monoliths, or over-engineered microservices that paralyze development.
AI Engineering & LLM Integration
Many AI initiatives fail in production due to prompt fragility, high token latency, hallucination risks, and lack of structured evaluation. I bridge the gap between experimental LLM prompts and deterministic software engineering.
Frequently Asked Questions
Why keep AI Recruiter and AI HR Platform as separate services instead of one monolith?
How do HMAC-SHA256 webhooks ensure safe offer-to-onboarding handoff?
How is employee PII protected when answering policy questions with an LLM?
Related Technical Articles
Zero-Trust Autonomous AI Agents: Enforcing Human-in-the-Loop Approvals via Telegram and AES-256 Vaults
A senior engineer's architectural blueprint for deploying autonomous AI agents in production safely: zero-trust credential vaults, interactive Telegram approval gateways, immutable SQLite audit trails, and deterministic fail-safes.
Auditing AI-Generated Web Applications for Production Readiness with AI App Production Auditor
How to statically audit AI-scaffolded full-stack applications for configuration drift, local endpoint leaks, and deployment risks using the zero-dependency AI App Production Auditor CLI.