Includes: API (Express/TypeScript), Astro site, Python workers, document generators, FCC compliance tools, Canada CRTC formation, Ansible infrastructure, and deployment scripts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
130 lines
5.1 KiB
Python
130 lines
5.1 KiB
Python
"""Employee Handbook / Policy Review handler (LLM-based).
|
|
|
|
Reviews existing employee handbooks for compliance with federal and state
|
|
employment laws, or develops new policies from scratch.
|
|
|
|
This handler is used for both "handbook-review" and "policy-development"
|
|
service slugs (different templates, same processing logic).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
from .base_handler import BaseServiceHandler
|
|
|
|
SERVICE_SYSTEM_PROMPT = """You are a compliance analyst at Performance West Inc.
|
|
generating an Employee Handbook & Policy Compliance Review report.
|
|
|
|
RULES:
|
|
- Write in professional, clear business English
|
|
- Reference specific federal laws (FMLA, ADA, Title VII, FLSA, OSHA, NLRA, etc.)
|
|
- Reference applicable state and local laws based on the client's locations
|
|
- Never provide legal advice — use "we recommend" not "you must"
|
|
- For each policy area: current state, applicable law, compliance gaps, recommended language
|
|
- Rate findings: Compliant, Needs Update, Missing, Non-Compliant
|
|
- Consider at-will employment disclaimers, anti-harassment, leave policies, etc.
|
|
"""
|
|
|
|
SECTIONS = [
|
|
{
|
|
"name": "executive_summary",
|
|
"prompt": (
|
|
"Write a 200-word executive summary of the handbook/policy review. "
|
|
"Include scope, overall compliance rating, number of policy areas "
|
|
"reviewed, and highest-priority gaps."
|
|
),
|
|
},
|
|
{
|
|
"name": "employment_relationship",
|
|
"prompt": (
|
|
"Review policies related to the employment relationship: at-will "
|
|
"disclaimers, equal employment opportunity, ADA accommodation, "
|
|
"anti-harassment/anti-discrimination, complaint procedures, and "
|
|
"immigration compliance (I-9). For each: status, applicable law, gaps."
|
|
),
|
|
},
|
|
{
|
|
"name": "compensation_and_hours",
|
|
"prompt": (
|
|
"Review wage and hour policies: pay periods, overtime, meal and "
|
|
"rest breaks, timekeeping, classifications, pay equity, and expense "
|
|
"reimbursement. Reference FLSA and applicable state wage laws."
|
|
),
|
|
},
|
|
{
|
|
"name": "leave_and_benefits",
|
|
"prompt": (
|
|
"Review leave policies: FMLA, state family/medical leave, sick leave, "
|
|
"PTO, jury duty, military leave (USERRA), voting leave, bereavement. "
|
|
"Assess benefit-related policies for ERISA and ACA compliance."
|
|
),
|
|
},
|
|
{
|
|
"name": "workplace_safety",
|
|
"prompt": (
|
|
"Review workplace safety and health policies: OSHA general duty, "
|
|
"hazard communication, workplace violence prevention, drug-free "
|
|
"workplace, workers' compensation, and remote work safety."
|
|
),
|
|
},
|
|
{
|
|
"name": "technology_and_privacy",
|
|
"prompt": (
|
|
"Review technology and privacy policies: electronic communications, "
|
|
"social media, BYOD, monitoring/surveillance disclosures, data "
|
|
"protection, and employee privacy rights under applicable state laws."
|
|
),
|
|
},
|
|
{
|
|
"name": "remediation_plan",
|
|
"prompt": (
|
|
"Provide a prioritized action plan for updating the handbook. "
|
|
"For each item: policy area, current status, required change, "
|
|
"applicable law, priority level, and recommended implementation timeline."
|
|
),
|
|
},
|
|
]
|
|
|
|
|
|
class HandbookReviewHandler(BaseServiceHandler):
|
|
SERVICE_SLUG = "handbook-review"
|
|
SERVICE_NAME = "Employee Handbook & Policy Review"
|
|
TEMPLATE_NAME = "handbook_review_template.docx"
|
|
REQUIRES_LLM = True
|
|
|
|
async def process(self, order_data: dict) -> list[str]:
|
|
work_dir = self._make_work_dir()
|
|
order_number = order_data["name"]
|
|
context = self._extract_order_context(order_data)
|
|
|
|
# Determine template based on item code (policy-development uses alt template)
|
|
items = order_data.get("items", [])
|
|
item_code = items[0].get("item_code", "") if items else ""
|
|
if item_code == "policy-development":
|
|
template_name = "policy_development_template.docx"
|
|
else:
|
|
template_name = self.TEMPLATE_NAME
|
|
|
|
template_path = self._get_template_path(template_name)
|
|
docx_filename = self._output_filename(order_number, "docx")
|
|
docx_path = os.path.join(work_dir, docx_filename)
|
|
|
|
variables = {
|
|
"order_number": order_number,
|
|
"customer_name": order_data.get("customer_name", ""),
|
|
"date": __import__("datetime").datetime.now().strftime("%B %d, %Y"),
|
|
"service_name": self.SERVICE_NAME,
|
|
"company_size": order_data.get("custom_company_size", "N/A"),
|
|
"industry": order_data.get("custom_industry", "N/A"),
|
|
"state": order_data.get("custom_state", "N/A"),
|
|
}
|
|
self._fill_template(template_path, variables, docx_path)
|
|
|
|
sections = await self._generate_sections(
|
|
SERVICE_SYSTEM_PROMPT, SECTIONS, context
|
|
)
|
|
self._add_sections_to_doc(docx_path, sections)
|
|
|
|
pdf_path = self._convert_to_pdf(docx_path)
|
|
return [docx_path, pdf_path]
|