PolicyOS
An auditable policy engine that turns workforce rules into deterministic, explainable assignments, with an MCP server so AI clients can ask why.
The problem
Companies assign things to employees by rule: expense limits, approvers, access, equipment. The rules overlap, change on specific dates, and depend on facts that keep moving, like who reports to whom. When an assignment is wrong, someone has to answer a simple question that is hard to answer: why did this person get this value?
PolicyOS is an independent implementation of a policy assignment system built to answer that question every time.

What it guarantees
- Versioned over time. Policies are immutable versions with effective-date ranges. Past assignments are recorded, today's are materialized, and future ones can be calculated without changing anything.
- Deterministic under overlap. Single-value fields resolve by priority and reject ambiguous ties. Multi-value fields combine unique values and keep track of where each came from.
- Reconciled when inputs change. Changes to employee facts, org relationships, groups, policies, dates and tenure thresholds trigger targeted or scheduled reconciliation.
- Safe to operate. Employee and policy changes can be previewed through the real domain services before they are committed.
- Built to explain. Every assignment stores an immutable explanation, and an append-only audit journal records who changed what.

Access and AI
PolicyOS supports multiple users with role-based access scoped by action, employee and field. Privileged writes require TOTP multi-factor authentication.
It also ships an MCP server. An MCP-compatible AI client can sign in as a user and ask it to explain a specific employee's expense limit, or preview what would change if that employee moved teams. The AI gets the same answers, under the same permissions, as a person using the app.

Running it
The whole stack starts with one command: docker compose up --build. Compose brings up PostgreSQL, applies the migrations, loads a fictional seeded company, and starts the FastAPI API, the Next.js frontend, the reconciliation scheduler and the MCP adapter.