# Stage 7 — Verification Agent (Reference / Background) (code)

After the human hire decision, this agent runs verification end to end: it captures the
candidate's written consent, triggers the checks, tracks and chases them, keeps the candidate
updated — and hands any flag to humans. It is the most compliance-sensitive agent in the set.

## The two hard gates (do not soften these)
- **GATE 1 — No consent, no check.** The agent requests written authorization first and will not
  initiate anything until it's signed. If consent stalls, it nudges, then escalates to the
  recruiter — it never proceeds without it. (FCRA requires a standalone disclosure + authorization.)
- **GATE 2 — No automated adverse action.** A FLAGGED result is routed to HR + the recruiter for the
  legally required human-led process (pre-adverse-action notice, copy of the report, time to
  dispute, then a final human decision). The agent takes **no action** on a flag and pauses all
  automated messaging to that candidate. California adds its own rules (e.g., Fair Chance Act), so
  HR owns everything after the hand-off.

## Files
- `stage7_verification_agent.py` — the agent.
- `stage7_candidates_sample.csv` — verification-stage candidates (your ATS exports this).
- `stage7_verification_sample.json` — check types per role, nudge/escalation windows, HR contact.
- `stage7_verification_README.md` — this file.

## What it does, by state
- **`consent_not_requested`** → sends the authorization request. Nothing else.
- **`consent_pending`** → friendly nudge at 2 days; escalates to the recruiter at 5. Never starts checks.
- **`consent_received`** → now (and only now) triggers the configured checks; tells the candidate.
- **`checks_in_progress`** → status updates to the candidate every few days; chases slow checks past 7 days.
- **`checks_complete` = clear** → advances to Offer with good news.
- **`checks_complete` = flagged** → human hand-off (Gate 2). No automated candidate message.

## Safety rails (built in)
- Dry-run by default; texts only with texting consent; audit log of every action.

## Run it
`python stage7_verification_agent.py` — watch all six paths, nothing is sent or triggered.

## Going live
1. Edit templates and windows in CONFIG.
2. Wire the PROVIDER HOOKS: `generate_consent_link` (e-signature form), `initiate_checks`
   (screening provider, e.g. Checkr/Certn/HireRight), `send_email`/`send_sms`, `notify_person`,
   `advance_stage` (ATS update).
3. `DRY_RUN = False`, test on your own addresses.
4. Have counsel or HR review your disclosure form and adverse-action letters — this stage is where
   the paperwork must be exactly right.

## Note on timing
`days_in_state`, `check_result`, and `days_since_update` simulate the clock and provider results so
you can see every path in one run. In production those come from your e-signature tool and screening
provider webhooks, and you run the agent on a schedule. Track sent nudges to avoid repeats.
