1. Spec
Say what the tool may calculate, which sources count, and what it must refuse to invent.
Plain language, then an agent, then a review
Gilbert Bouic did not hand-code this repository. He wrote a specification in ordinary language. An AI coding agent turned that into the API, the tests, the evals and this site. A human still has to check every legal figure.
Say what the tool may calculate, which sources count, and what it must refuse to invent.
The specification below is the prompt the coding agent received. The prompts are kept, not summarised away.
Read the diff. Run pytest and the no-LLM eval. Publish the static site. Do not merge on the agent's word.
The LangGraph agent plans three tools and calls them in order: the versioned rate file, the deterministic calculator, then a search over the local Chroma index. Embeddings come from a sentence-transformer model on the machine. No paid key is required. An LLM is optional. With none configured, the legal note is an extract from the passages.
The agent has no approve tool. POST /v1/payslips/{id}/approve is a separate call, and it demands an explicit confirmation sentence. Logs redact wages, emails and employee references.
If retrieval finds no passage above the similarity threshold, the answer is a refusal. The model is not asked to guess.
Responses are Pydantic models. The agent schema literally cannot carry the status “approved”.
An LLM answer that introduces a rupee amount or a percentage absent from the passages is discarded. The extractive quote is returned instead.
The labelled set lives in evals/cases.json. Expected calculation answers were worked from the verified config, not copied out of a previous run of the same function. The sample below is the committed no-LLM report.
| Metric | No-LLM sample |
|---|---|
| Calculation accuracy | 10/10 |
| Citation correctness | 13/13 |
| Hallucination rate | 0/13 |
| Refusal rate, where a refusal is required | 2/2 |
| False refusals | 0/13 |
| Agent drafts kept at pending approval | 2/2 |
| Mean latency | 4.6 ms (p95 10.2 ms) |
| Tokens / estimated cost | 0 / USD 0.00 |
These figures are the no-LLM sample in evals/reports/sample-no-llm.md. Latency will differ on another machine. The pass counts are the contract.
The employer circular of 6 October 2025 says PAYE is not deducted when monthly emoluments do not exceed Rs 38,462, and it uses that figure for an employee with no EDF. The Guide on Income Tax dated December 2025 still says Rs 30,000 in its no-EDF paragraphs. The calculator follows the circular. Someone has to confirm which threshold the MRA applies in practice.
Section 18(5C) of the Human Resource Development Act sets a 1.5% levy only from 1 July 2023 to 30 June 2025. A first reading treats that as the end of the rate. The First Schedule still says “one and a half per cent”, and the October 2025 MRA guide still says 1.5% as from July 2021. Confirm that no later gazette replaced the Schedule.
The bonus row in Table 4 is Rs 5,538,562, which is Rs 100 above 6 × 923,077. Several later months differ by Rs 1 from a strict multiple. The file keeps the published figures. It does not “correct” the table.
The same October 2025 guide has a general list that names final retirement age 70 for NPF, NSF and the levy, and a specific NSF section that says nothing is payable from retirement age 65. The calculator follows the specific NSF section, and age 70 for the levy. Confirm the reading.
Section 23(6) states an allowance of 15 per cent. Section 23(7) says the worker is not entitled to it until a further period is prescribed. The corpus keeps both sentences in one passage.
The guide gives a domestic row only where the basic wage does not exceed Rs 3,000. The tool returns UNVERIFIED and does not copy the private-sector rates onto that case. Rounding of CSG, NSF and the levy to the cent is also UNVERIFIED. PAYE rounded down to the rupee is stated.
The PAYE page tells the employer to apply “the table under point 2”, which on that page is the annual bands, inside a cumulative calculation. The circular publishes month-by-month bands in Table 3. This tool uses Table 3 so withholding is spread through the year. That is a reading, and it needs a human.
These are the specification prompts sent to the coding agent. The agent also runs under its own product instructions. Those are not part of this repository, and they are not copied here.
Build out this repo (currently only a 2-line README) and open ONE pull request against main. Do not merge. Owner context: Gilbert Bouic (Mkweli, mkweli.tech) builds public-interest tools in Mauritius by directing AI coding agents rather than hand-coding. Public name for this product: "Mkweli Payroll". Domain: payroll.mkweli.tech (DNS CNAME already points to gilbertbouic.github.io). Zero legal risk: every legal/tax figure must be attributed to an official source (MRA, Workers' Rights Act 2019, Government Gazette/Finance Act), with a clear 'not legal or tax advice; check with MRA or a professional' disclaimer. No personal phone/email; contact via mkweli.tech only. Never use the words 'movement' or 'campaign'. Part A: Python backend in /backend (as the README describes): a RAG API over Mauritius payroll law. FastAPI + Pydantic v2. Ingestion script for a small curated corpus of official public sources (store source URLs + retrieval date; include text excerpts only where licensing allows, otherwise fetch at ingest time). Lightweight local retrieval (e.g. BM25 or sentence-transformers optional; must run with no paid API key; LLM step optional/pluggable via env var, with a no-LLM extractive answer mode). Every answer returns citations (source title, URL, section). Refusal guardrails when no supporting passage. Also a deterministic payroll calculator module (PAYE, CSG employee/employer, NSF, training levy, minimum wage check) with rates in a single versioned config file per income year (2025-26) each carrying its source URL; research current figures from MRA/official sources and mark anything you could not verify as UNVERIFIED rather than guessing. pytest tests, requirements.txt, Dockerfile, .env.example (no secrets committed). Part B: Static showcase site in /docs for GitHub Pages (plain HTML/CSS/JS, no Hugging Face, no video embeds, no backend calls), with a CNAME file containing exactly `payroll.mkweli.tech`. Bilingual EN + FR (natural French, not calques: 'cotisations', 'impôt sur le revenu (PAYE)', 'loi sur les droits des travailleurs'). Content: what Mkweli Payroll is; a client-side calculator using the same rates config exported as JSON (with sources shown per figure and the disclaimer); and a page 'How I built this with AI' showing the actual workflow: plain-language spec -> AI coding agent prompts (include the real prompts used, as code blocks) -> review -> tests -> deploy, with honest notes on what AI got wrong and what a human must check (legal figures). Style consistent with a clean, minimal transparency site. Screenshot-ready. Update README.md (EN) explaining both parts, how to run the backend locally, and how to deploy docs/ via GitHub Pages (Settings > Pages > main /docs, custom domain payroll.mkweli.tech). In the PR description: summary, list of every rate with source and verification status, screenshots of the showcase pages (EN calculator, FR calculator, How I built this).
Scope extension (owner approved). Keep everything already specified, and add, in the same PR: 1) Agent: a LangGraph agent in /backend that handles requests like 'run payroll for this employee' (gross salary, income year, deductions): plans and calls tools in sequence (rates lookup from the versioned config, deterministic calculator, legal citation search over the RAG index) and returns a payslip draft. Expose via FastAPI endpoint. 2) RAG: use embeddings + a vector DB (Chroma or pgvector; default Chroma local, with a free local embedding model like sentence-transformers so no paid key is needed). LLM pluggable via env (OpenAI/Anthropic/none) with extractive fallback. 3) Structured outputs + guardrails: Pydantic-validated responses, refusal when no supporting source, and a human-approval step (payslip draft status 'pending_approval' until an approve endpoint is called; agent can never mark final itself). Redact/avoid logging personal data. 4) Evaluation suite in /evals: a labelled set of payroll questions and calculation cases with known answers (from verified config only), a script reporting accuracy, citation correctness, hallucination/refusal rate, latency, and token usage/cost per run; output a markdown report, and include a sample report run in no-LLM mode. 5) Deployment: Dockerfile + docker-compose, GitHub Actions CI running pytest and the evals (no-LLM mode), and a documented one-command AWS deploy option (e.g. App Runner or ECS via a simple script/template) without requiring credentials in repo. Also update the static 'How I built this with AI' pages (EN/FR) to describe the agent architecture (a mermaid-style or SVG diagram), the eval results table, and the safeguards; frame the project as 'safe AI for regulated payroll'. Update README accordingly. Report back the PR URL, the eval summary numbers, and screenshots.