Drift agent (experimental)
June 20, 2026 · View on GitHub
Status: experimental / human-in-the-loop
This is not self-healing production infrastructure. It assists engineers when vendor payloads drift from expected schemas.
What it does
- Polls
GET /drift/events?status=pending&includePayload=true(requiresDRIFT_AGENT_TOKEN) - Writes Vitest fixtures from failed payloads
- Uses an LLM (OpenAI via LlamaIndex) to propose TypeScript mapper patches
- Outputs suggestions under
agents/output/— not applied automatically
What it does not do
- Deploy or hot-reload mappers in production
- Bypass code review or CI
- Guarantee correct patches (always validate with
npm test) - Replace operator investigation of the drift queue
When to use it
| Good fit | Poor fit |
|---|---|
| Accelerating fixture + patch drafts after a vendor schema change | Unattended production cron without human review |
| Local dev against a SQLite copy | Teams without LLM API budget / policy |
| CI hourly dry-run with manual merge | Expectation of "auto-fix" SLAs |
Setup
pip install -r agents/drift_runner/requirements.txt
# Local SQLite
python -m agents.drift_runner --database data/unischema.db
# Production API (read-only drift export)
python -m agents.drift_runner \
--api-url https://unischema.example.com \
--token "$DRIFT_AGENT_TOKEN"
Required secrets: DRIFT_AGENT_TOKEN, OPENAI_API_KEY (optional DRIFT_AGENT_MODEL).
Operator workflow
- Drift event appears after webhook validation failure
- Engineer runs agent locally or via GitHub Action (
.github/workflows/drift-agent.yml) - Review
agents/output/patch proposal - Run tests, adjust, open PR
POST /drift/events/:id/ackafter merge/deploy
Autogenerated fixtures (tests/autogenerated/)
When the drift agent or CI generates fixtures from production drift events, files land under tests/autogenerated/. Policy:
- Never auto-merge autogenerated PRs without human review
- Redact PII before committing fixtures
- Run
npm run validatebefore merge
See .github/workflows/drift-on-mapper-failure.yml for CI integration.
The hourly workflow is a scaffold — configure repository secrets and treat outputs as draft PRs, not auto-merge.
Optional draft PR after patch generation:
python -m agents.drift_runner --database data/unischema.db --create-pr
Requires gh CLI authenticated. Human review required before merge.
See docs/operator-guide.md for the full operator path.