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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AICL Example: HR Management System
|
| 2 |
+
# End-to-end human resources management system covering employee lifecycle, payroll processing, benefits administration, performance management, and recruitment with compliance automation
|
| 3 |
+
|
| 4 |
+
Goal: Provide a comprehensive human resources management platform that automates the entire employee lifecycle from recruitment through offboarding, ensures payroll accuracy across jurisdictions, streamlines benefits enrollment, enables continuous performance management, and maintains regulatory compliance with labor laws and data privacy regulations
|
| 5 |
+
|
| 6 |
+
Constraint: All employee personal data must be encrypted and access-logged with role-based restrictions enforcing least-privilege principles
|
| 7 |
+
Constraint: Payroll calculations must comply with federal, state, and local tax regulations with automated table updates
|
| 8 |
+
Constraint: Performance evaluations must follow structured rubrics preventing unauthorized modification after submission
|
| 9 |
+
Constraint: Recruitment processes must enforce equal opportunity compliance with bias detection on job postings and screening criteria
|
| 10 |
+
Constraint: Benefits enrollment must honor plan eligibility rules, coverage periods, and qualifying life event windows
|
| 11 |
+
|
| 12 |
+
Risk: Payroll miscalculation due to incorrect tax jurisdiction assignment or outdated rate tables
|
| 13 |
+
Recovery: Halt affected payroll run immediately; revert to last validated tax configuration; recalculate using corrected tables; generate adjustment entries with full audit trail; notify affected employees and finance team
|
| 14 |
+
|
| 15 |
+
Risk: Unauthorized access to employee sensitive data including salary and medical information
|
| 16 |
+
Recovery: Revoke compromised access credentials; audit all recent data access logs; notify affected employees per breach notification requirements; enforce mandatory access review; implement additional authentication layer
|
| 17 |
+
|
| 18 |
+
Risk: Recruitment bias in automated screening causing discriminatory candidate filtering
|
| 19 |
+
Recovery: Disable automated screening rule immediately; revert to manual review process; audit screening criteria for protected class correlations; re-evaluate all affected candidates; report findings to compliance and legal
|
| 20 |
+
|
| 21 |
+
Risk: Benefits enrollment processing failure during open enrollment period
|
| 22 |
+
Recovery: Extend enrollment deadline automatically; switch to manual processing queue; preserve all submitted elections; notify HR and benefits team; engage carrier liaison for deadline accommodation; log incident for post-mortem
|
| 23 |
+
|
| 24 |
+
Risk: Performance review data loss before manager submission
|
| 25 |
+
Recovery: Enable auto-save with 30-second intervals; restore from last autosave checkpoint; maintain versioned drafts; prevent form timeout during active editing; notify user of recovery action taken
|
| 26 |
+
|
| 27 |
+
Risk: Employee offboarding incomplete leaving active access to systems and data
|
| 28 |
+
Recovery: Trigger comprehensive offboarding checklist on termination date; automatically revoke all system access within 1 hour; verify deprovisioning completion; escalate incomplete items to IT security; generate compliance attestation report
|
| 29 |
+
|
| 30 |
+
Layer: EmployeeLifecycle
|
| 31 |
+
SubLayer: Onboarding
|
| 32 |
+
SubLayer: EmployeeRecords
|
| 33 |
+
SubLayer: Transfers
|
| 34 |
+
SubLayer: Offboarding
|
| 35 |
+
|
| 36 |
+
Layer: Payroll
|
| 37 |
+
SubLayer: TimeTracking
|
| 38 |
+
SubLayer: TaxCalculation
|
| 39 |
+
SubLayer: DeductionEngine
|
| 40 |
+
SubLayer: PaymentProcessing
|
| 41 |
+
|
| 42 |
+
Layer: Benefits
|
| 43 |
+
SubLayer: PlanManagement
|
| 44 |
+
SubLayer: EnrollmentEngine
|
| 45 |
+
SubLayer: ClaimsCoordination
|
| 46 |
+
SubLayer: COBRASystems
|
| 47 |
+
|
| 48 |
+
Layer: Performance
|
| 49 |
+
SubLayer: GoalSetting
|
| 50 |
+
SubLayer: ReviewCycles
|
| 51 |
+
SubLayer: FeedbackEngine
|
| 52 |
+
SubLayer: SuccessionPlanning
|
| 53 |
+
|
| 54 |
+
Layer: Recruitment
|
| 55 |
+
SubLayer: RequisitionManagement
|
| 56 |
+
SubLayer: ApplicantTracking
|
| 57 |
+
SubLayer: InterviewScheduling
|
| 58 |
+
SubLayer: OfferManagement
|
| 59 |
+
|
| 60 |
+
Validation: Payroll gross-to-net calculations must pass tolerance check within 0.01 percent of expected values
|
| 61 |
+
Validation: Performance review submissions must include self-assessment, manager assessment, and at least one peer review
|
| 62 |
+
Validation: Benefits enrollment selections must not exceed plan maximums or create coverage gaps
|
| 63 |
+
Validation: Job requisitions must include approved headcount budget and validated department code
|
| 64 |
+
Validation: Employee offboarding must complete all checklist items before final paycheck release
|
| 65 |
+
Validation: Time entries must fall within authorized schedule windows and comply with overtime regulations
|
| 66 |
+
|
| 67 |
+
Entity EmployeeRecord
|
| 68 |
+
employeeId: string
|
| 69 |
+
firstName: string
|
| 70 |
+
lastName: string
|
| 71 |
+
dateOfBirth: datetime
|
| 72 |
+
ssnEncrypted: bytes
|
| 73 |
+
email: string
|
| 74 |
+
phone: string
|
| 75 |
+
address: dict
|
| 76 |
+
department: string
|
| 77 |
+
jobGrade: string
|
| 78 |
+
hireDate: datetime
|
| 79 |
+
employmentStatus: string
|
| 80 |
+
managerId: string
|
| 81 |
+
workLocation: string
|
| 82 |
+
|
| 83 |
+
Entity PayrollRun
|
| 84 |
+
payrollRunId: string
|
| 85 |
+
payPeriodStart: datetime
|
| 86 |
+
payPeriodEnd: datetime
|
| 87 |
+
runDate: datetime
|
| 88 |
+
status: string
|
| 89 |
+
totalGross: float
|
| 90 |
+
totalTaxes: float
|
| 91 |
+
totalDeductions: float
|
| 92 |
+
totalNet: float
|
| 93 |
+
employeeCount: integer
|
| 94 |
+
jurisdiction: string
|
| 95 |
+
processingMode: string
|
| 96 |
+
|
| 97 |
+
Entity BenefitsEnrollment
|
| 98 |
+
enrollmentId: string
|
| 99 |
+
employeeId: string
|
| 100 |
+
planYear: string
|
| 101 |
+
medicalPlan: string
|
| 102 |
+
dentalPlan: string
|
| 103 |
+
visionPlan: string
|
| 104 |
+
lifeInsurance: string
|
| 105 |
+
retirementPlan: string
|
| 106 |
+
fsaContribution: float
|
| 107 |
+
hsaContribution: float
|
| 108 |
+
dependents: list
|
| 109 |
+
enrollmentDate: datetime
|
| 110 |
+
qualifyingEvent: string
|
| 111 |
+
|
| 112 |
+
Entity PerformanceReview
|
| 113 |
+
reviewId: string
|
| 114 |
+
employeeId: string
|
| 115 |
+
reviewerId: string
|
| 116 |
+
reviewCycle: string
|
| 117 |
+
selfAssessment: dict
|
| 118 |
+
managerAssessment: dict
|
| 119 |
+
peerReviews: list
|
| 120 |
+
goalProgress: list
|
| 121 |
+
overallRating: float
|
| 122 |
+
competencyScores: dict
|
| 123 |
+
developmentPlan: dict
|
| 124 |
+
status: string
|
| 125 |
+
submittedDate: datetime
|
| 126 |
+
|
| 127 |
+
Entity JobRequisition
|
| 128 |
+
requisitionId: string
|
| 129 |
+
jobTitle: string
|
| 130 |
+
department: string
|
| 131 |
+
hiringManager: string
|
| 132 |
+
headcountBudget: float
|
| 133 |
+
salaryRange: dict
|
| 134 |
+
employmentType: string
|
| 135 |
+
location: string
|
| 136 |
+
requiredSkills: list
|
| 137 |
+
preferredSkills: list
|
| 138 |
+
postingDate: datetime
|
| 139 |
+
targetFillDate: datetime
|
| 140 |
+
approvalStatus: string
|
| 141 |
+
diversityRequirements: dict
|
| 142 |
+
|
| 143 |
+
Entity TimeEntry
|
| 144 |
+
entryId: string
|
| 145 |
+
employeeId: string
|
| 146 |
+
date: datetime
|
| 147 |
+
hours: float
|
| 148 |
+
timeType: string
|
| 149 |
+
project: string
|
| 150 |
+
approvalStatus: string
|
| 151 |
+
approvedBy: string
|
| 152 |
+
overtimeHours: float
|
| 153 |
+
breakDuration: integer
|
| 154 |
+
location: string
|
| 155 |
+
|
| 156 |
+
Behavior ProcessPayrollRun
|
| 157 |
+
Input: payPeriodStart: datetime, payPeriodEnd: datetime, jurisdiction: string
|
| 158 |
+
Output: payrollRunResult: PayrollRun
|
| 159 |
+
Action: Load active employee roster for period; aggregate approved time entries; calculate gross compensation including overtime; apply federal state and local tax withholdings; process benefit deductions; calculate employer contributions; validate net pay tolerances; generate payment file; create payroll journal entries; emit payroll completed event
|
| 160 |
+
|
| 161 |
+
Behavior EnrollBenefits
|
| 162 |
+
Input: employeeId: string, planYear: string, selections: dict, qualifyingEvent: string
|
| 163 |
+
Output: enrollmentConfirmation: BenefitsEnrollment
|
| 164 |
+
Action: Verify employee eligibility for each selected plan; validate enrollment window or qualifying event; check dependent eligibility; compute employee and employer cost shares; validate total contribution limits; persist enrollment; transmit to benefits carrier; emit enrollment confirmed event; update payroll deduction schedule
|
| 165 |
+
|
| 166 |
+
Behavior SubmitPerformanceReview
|
| 167 |
+
Input: reviewId: string, assessmentData: dict, reviewerType: string
|
| 168 |
+
Output: submissionConfirmation: dict
|
| 169 |
+
Action: Validate review period is open; check reviewer authorization; enforce required assessment sections; compute overall rating from competency scores; detect and flag calibration outliers; persist submission; check if all required reviews are complete; emit review submitted event; trigger next step in review workflow
|
| 170 |
+
|
| 171 |
+
Behavior ProcessOffboarding
|
| 172 |
+
Input: employeeId: string, terminationDate: datetime, reason: string
|
| 173 |
+
Output: offboardingResult: dict
|
| 174 |
+
Action: Generate offboarding checklist; schedule exit interview; initiate benefits continuation processing; calculate final paycheck including PTO payout; trigger system access revocation; transfer knowledge responsibilities; archive employee records per retention policy; emit offboarding initiated event; generate compliance attestation
|
| 175 |
+
|
| 176 |
+
Behavior CreateJobRequisition
|
| 177 |
+
Input: jobTitle: string, department: string, hiringManager: string, salaryRange: dict, requirements: dict
|
| 178 |
+
Output: requisition: JobRequisition
|
| 179 |
+
Action: Validate headcount budget availability; check department approval chain; scan job description for biased language; validate required fields; apply approval workflow based on grade and salary range; persist requisition; emit requisition created event; initiate recruiting workflow; update workforce planning dashboard
|
| 180 |
+
|
| 181 |
+
Behavior ApproveTimeEntries
|
| 182 |
+
Input: managerId: string, entryIds: list, approvalDecision: string, notes: string
|
| 183 |
+
Output: approvalResult: dict
|
| 184 |
+
Action: Verify manager authorization for submitted employees; validate hours against schedule policies; check overtime compliance; apply approval or rejection; update entry status; recalculate overtime if applicable; emit time entry approved event; flag exceptions for HR review; update time and attendance records
|
| 185 |
+
|
| 186 |
+
Condition:
|
| 187 |
+
When employee.employmentStatus changes to "terminated" AND employee has active benefits enrollment
|
| 188 |
+
Then initiate COBRA notification process within 14 days; generate benefits continuation election form; set coverage end date per plan rules; notify benefits carrier; update payroll deduction termination schedule
|
| 189 |
+
|
| 190 |
+
Condition:
|
| 191 |
+
When timeEntry.overtimeHours exceeds 20 in a single workweek
|
| 192 |
+
Then flag for manager and HR review; verify compliance with labor regulations; calculate premium pay rate adjustments; alert workforce management; generate overtime exception report
|
| 193 |
+
|
| 194 |
+
Condition:
|
| 195 |
+
When performanceReview.overallRating deviates more than 1.5 standard deviations from team average
|
| 196 |
+
Then trigger calibration review workflow; notify HR business partner; require additional justification from reviewer; hold review in pending calibration status; log deviation for trend analysis
|
| 197 |
+
|
| 198 |
+
Condition:
|
| 199 |
+
When benefitsEnrollment.fsContribution exceeds annual IRS limit
|
| 200 |
+
Then reject contribution election; notify employee and HR; apply maximum allowable contribution; generate limit notification; adjust payroll deduction accordingly
|
| 201 |
+
|
| 202 |
+
Condition:
|
| 203 |
+
When jobRequisition job description contains potential bias indicators per NLP analysis
|
| 204 |
+
Then flag posting for diversity and inclusion review; suggest alternative neutral language; prevent publishing until review cleared; log bias detection results; update screening criteria audit trail
|
| 205 |
+
|
| 206 |
+
Event:
|
| 207 |
+
On PayrollRunCompleted
|
| 208 |
+
Action: Submit payment file to banking system; post payroll journal entries to finance; update employee year-to-date accumulations; generate payslip notifications; sync benefits deductions with carriers; archive payroll register
|
| 209 |
+
|
| 210 |
+
Event:
|
| 211 |
+
On BenefitsEnrollmentConfirmed
|
| 212 |
+
Action: Update payroll deduction configuration; transmit enrollment to carrier; generate employee confirmation statement; update benefits dashboard; trigger ID card issuance if applicable; log enrollment for compliance reporting
|
| 213 |
+
|
| 214 |
+
Event:
|
| 215 |
+
On PerformanceReviewCycleClosed
|
| 216 |
+
Action: Calculate compensation adjustment recommendations; generate talent review summaries; update succession planning data; trigger development plan creation; publish aggregate analytics to leadership; archive review documents
|
| 217 |
+
|
| 218 |
+
Event:
|
| 219 |
+
On EmployeeOffboardingComplete
|
| 220 |
+
Action: Verify all access revoked; generate final compliance attestation; transfer records to archive; update headcount reporting; process alumni network enrollment; close outstanding HR tickets; release final paycheck
|
| 221 |
+
|
| 222 |
+
Event:
|
| 223 |
+
On JobRequisitionApproved
|
| 224 |
+
Action: Publish to internal and external job boards; activate applicant tracking workflow; schedule recruiter briefing; configure screening automation; set diversity sourcing targets; notify hiring manager of posting
|
| 225 |
+
|
| 226 |
+
Parallel:
|
| 227 |
+
- Payroll gross-to-net calculation engine per jurisdiction
|
| 228 |
+
- Benefits enrollment validation and carrier transmission
|
| 229 |
+
- Performance review calibration analytics
|
| 230 |
+
- Recruitment screening pipeline execution
|
| 231 |
+
- Employee data privacy compliance monitoring
|
| 232 |
+
|
| 233 |
+
Optimize: Employee experience and payroll processing accuracy
|
| 234 |
+
Priority: Payroll accuracy and tax compliance over processing speed
|
| 235 |
+
Priority: Data privacy and access control over analytics convenience
|
| 236 |
+
Priority: Employee self-service responsiveness over administrative batch efficiency
|
| 237 |
+
Priority: Recruitment fairness and compliance over time-to-fill metrics
|
| 238 |
+
|
| 239 |
+
Learn: Employee attrition prediction
|
| 240 |
+
Goal: Identify flight risk employees 90 days before voluntary departure with 70 percent recall
|
| 241 |
+
Adapt: Retention intervention triggers and timing
|
| 242 |
+
Based: Engagement survey trends, compensation market positioning, tenure patterns, and manager effectiveness scores
|
| 243 |
+
|
| 244 |
+
Learn: Compensation benchmarking accuracy
|
| 245 |
+
Goal: Maintain salary recommendations within 5 percent of market median
|
| 246 |
+
Adapt: Salary range adjustments and offer guidance
|
| 247 |
+
Based: Market survey data, internal equity analysis, and candidate acceptance rate trends
|
| 248 |
+
|
| 249 |
+
Learn: Time-to-hire optimization
|
| 250 |
+
Goal: Reduce average time-to-hire by 30 percent without sacrificing quality of hire
|
| 251 |
+
Adapt: Interview stage configurations and screening criteria
|
| 252 |
+
Based: Stage duration analytics, candidate pipeline velocity, and quality-of-hire outcomes
|
| 253 |
+
|
| 254 |
+
Learn: Benefits utilization efficiency
|
| 255 |
+
Goal: Optimize plan offerings to maximize employee satisfaction while controlling cost per employee
|
| 256 |
+
Adapt: Plan recommendation engine and enrollment guidance
|
| 257 |
+
Based: Claims utilization patterns, employee satisfaction surveys, and cost trend analysis
|
| 258 |
+
|
| 259 |
+
Security:
|
| 260 |
+
Encrypt: All employee personally identifiable information including SSN, date of birth, and medical data
|
| 261 |
+
Encrypt: Salary and compensation data at rest and in transit with field-level encryption
|
| 262 |
+
Encrypt: Banking details for direct deposit with hardware security module key management
|
| 263 |
+
Protect: Payroll processing initiation with dual-authorization and segregation of duties
|
| 264 |
+
Protect: Performance review data with manager-only access and HR oversight audit trail
|
| 265 |
+
Protect: Recruitment candidate data with anonymization during screening phase
|
| 266 |
+
Protect: Benefits enrollment and claims data with HIPAA-compliant access controls
|
| 267 |
+
|
| 268 |
+
Native: python
|
| 269 |
+
{
|
| 270 |
+
from datetime import datetime, date, timedelta
|
| 271 |
+
from decimal import Decimal
|
| 272 |
+
from typing import Dict, List, Optional
|
| 273 |
+
|
| 274 |
+
class PayrollCalculator:
|
| 275 |
+
"""Multi-jurisdiction payroll calculation engine with tax compliance."""
|
| 276 |
+
|
| 277 |
+
def __init__(self, tax_tables: Dict, benefit_rules: Dict):
|
| 278 |
+
self.tax_tables = tax_tables
|
| 279 |
+
self.benefit_rules = benefit_rules
|
| 280 |
+
|
| 281 |
+
def calculate_gross_to_net(self, employee: Dict, time_entries: List[Dict]) -> Dict:
|
| 282 |
+
gross = self._calculate_gross(employee, time_entries)
|
| 283 |
+
taxes = self._calculate_taxes(gross, employee)
|
| 284 |
+
deductions = self._calculate_deductions(gross, employee)
|
| 285 |
+
net = gross - taxes["total"] - deductions["total"]
|
| 286 |
+
|
| 287 |
+
return {
|
| 288 |
+
"employee_id": employee["employee_id"],
|
| 289 |
+
"gross_pay": float(gross),
|
| 290 |
+
"federal_tax": float(taxes["federal"]),
|
| 291 |
+
"state_tax": float(taxes["state"]),
|
| 292 |
+
"local_tax": float(taxes.get("local", Decimal("0"))),
|
| 293 |
+
"social_security": float(taxes["social_security"]),
|
| 294 |
+
"medicare": float(taxes["medicare"]),
|
| 295 |
+
"benefit_deductions": float(deductions["benefits"]),
|
| 296 |
+
"retirement_deductions": float(deductions["retirement"]),
|
| 297 |
+
"other_deductions": float(deductions["other"]),
|
| 298 |
+
"net_pay": float(net),
|
| 299 |
+
"calculation_timestamp": datetime.utcnow().isoformat()
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
def _calculate_gross(self, employee: Dict, entries: List[Dict]) -> Decimal:
|
| 303 |
+
regular_hours = sum(e["hours"] for e in entries if e["time_type"] == "regular")
|
| 304 |
+
overtime_hours = sum(e["hours"] for e in entries if e["time_type"] == "overtime")
|
| 305 |
+
hourly_rate = Decimal(str(employee["salary"])) / Decimal("2080")
|
| 306 |
+
return (hourly_rate * Decimal(str(regular_hours)) +
|
| 307 |
+
hourly_rate * Decimal("1.5") * Decimal(str(overtime_hours)))
|
| 308 |
+
|
| 309 |
+
def _calculate_taxes(self, gross: Decimal, employee: Dict) -> Dict:
|
| 310 |
+
federal = self._federal_withholding(gross, employee)
|
| 311 |
+
state = self._state_withholding(gross, employee)
|
| 312 |
+
ss = min(gross * Decimal("0.062"), Decimal("9932"))
|
| 313 |
+
medicare = gross * Decimal("0.0145")
|
| 314 |
+
return {
|
| 315 |
+
"federal": federal, "state": state,
|
| 316 |
+
"local": Decimal("0"), "social_security": ss,
|
| 317 |
+
"medicare": medicare,
|
| 318 |
+
"total": federal + state + Decimal("0") + ss + medicare
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
def _calculate_deductions(self, gross: Decimal, employee: Dict) -> Dict:
|
| 322 |
+
benefits = Decimal(str(employee.get("benefit_deduction", "0")))
|
| 323 |
+
retirement = gross * Decimal(str(self.benefit_rules.get("401k_rate", 0.05)))
|
| 324 |
+
return {
|
| 325 |
+
"benefits": benefits, "retirement": retirement,
|
| 326 |
+
"other": Decimal("0"),
|
| 327 |
+
"total": benefits + retirement
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
class OffboardingChecklist:
|
| 332 |
+
"""Manages comprehensive employee offboarding with compliance tracking."""
|
| 333 |
+
|
| 334 |
+
def __init__(self, system_registry: Dict):
|
| 335 |
+
self.systems = system_registry
|
| 336 |
+
self.required_items = [
|
| 337 |
+
"system_access_revocation", "equipment_return",
|
| 338 |
+
"knowledge_transfer", "exit_interview",
|
| 339 |
+
"final_paycheck_calculation", "benefits_continuation",
|
| 340 |
+
"records_archive", "compliance_attestation"
|
| 341 |
+
]
|
| 342 |
+
|
| 343 |
+
def execute_offboarding(self, employee_id: str, termination_date: date) -> Dict:
|
| 344 |
+
results = {}
|
| 345 |
+
for item in self.required_items:
|
| 346 |
+
handler = getattr(self, f"_process_{item}", None)
|
| 347 |
+
if handler:
|
| 348 |
+
results[item] = handler(employee_id, termination_date)
|
| 349 |
+
return {
|
| 350 |
+
"employee_id": employee_id,
|
| 351 |
+
"termination_date": termination_date.isoformat(),
|
| 352 |
+
"items_completed": sum(1 for v in results.values() if v["status"] == "complete"),
|
| 353 |
+
"items_pending": sum(1 for v in results.values() if v["status"] == "pending"),
|
| 354 |
+
"details": results,
|
| 355 |
+
"compliance_attested": all(v["status"] == "complete" for v in results.values())
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
def _process_system_access_revocation(self, emp_id: str, term_date: date) -> Dict:
|
| 359 |
+
revoked = []
|
| 360 |
+
for system_name, system in self.systems.items():
|
| 361 |
+
try:
|
| 362 |
+
system.revoke_access(emp_id, term_date)
|
| 363 |
+
revoked.append(system_name)
|
| 364 |
+
except Exception as e:
|
| 365 |
+
return {"status": "pending", "error": str(e), "revoked": revoked}
|
| 366 |
+
return {"status": "complete", "revoked": revoked}
|
| 367 |
+
}
|