Managers approve their own reports
The email macro sends a report to the manager field, even when that is the submitter.
Impact: Audit finding 2026-14 against the controls of the finance team.
All problemsData & Systems
Build an expense approval engine from a one-page spec.
Your mission · Build from a spec
An internal audit found a regional manager who approved his own $3,800 hotel bill, and 412 reports that have waited more than 30 days because the email routing lost them. The auditors want a fix in place by January 15, or the finance team must review every report by hand.
The email macro sends a report to the manager field, even when that is the submitter.
Impact: Audit finding 2026-14 against the controls of the finance team.
A rejected report goes nowhere, and nobody knows who must act next.
Impact: 412 reports waiting more than 30 days to be paid.
Routing and decisions raise NotImplementedError.
Impact: The engine cannot replace the macro before January 15.
Edit the components marked “Your work”. The other components show where your changes fit.
| Field | Type | Notes |
|---|---|---|
people | {id: {manager}} | Everyone who submits or approves. The top of the org has manager null. |
second_level_over | integer cents | Over this, the manager's manager approves too. Larkspur: 100000 ($1,000). |
finance_over | integer cents | Over this, finance approves last. Larkspur: 500000 ($5,000). |
finance, fallback | person id | The finance approver, and internal audit for steps nobody else can take. |
categories | {name: approver or null} | Software needs the IT lead. |
| Field | Type | Notes |
|---|---|---|
report | string | The expense app's id, for example "EXP-7102". |
employee | person id | The submitter. |
amount | integer cents | 1 or more. |
chain, step | person ids, index | Who approves, in order, and who is next. |
state | "pending", "returned" or "approved" | |
entries | list | The decision log, oldest first. |
config/policy.json Larkspur's finance policy in the format simulate reads: the org chart, the two thresholds and the category approvers.{
"people": {
"olu": {
"manager": null
},
"dee": {
"manager": "olu"
},
"lee": {
"manager": "olu"
},
"fay": {
"manager": "olu"
},
"ann": {
"manager": "olu"
},
"raj": {
"manager": "dee"
},
"mia": {
"manager": "dee"
},
"tom": {
"manager": "raj"
},
"kim": {
"manager": "raj"
}
},
"second_level_over": 100000,
"finance_over": 500000,
"finance": "fay",
"fallback": "ann",
"categories": {
"travel": null,
"meals": null,
"tools": null,
"software": "lee"
}
}docs/org-chart.md Who each id in the policy is, and their role.# Who is who in the policy | id | Role | Manager | | --- | --- | --- | | olu | Chief operating officer | none | | dee | VP field operations | olu | | lee | IT lead, approves software | olu | | fay | Finance controller, approves over $5,000 | olu | | ann | Internal audit, the fallback approver | olu | | raj | Regional manager, Ohio Valley | dee | | mia | Regional manager, Great Lakes | dee | | tom | Elevator technician | raj | | kim | HVAC technician | raj |
samples/one-week.json A small week: four reports, one rejected and resubmitted, a manager's own report and the IT lead's own software. Arguments for Preview.[
{
"people": {
"olu": {
"manager": null
},
"dee": {
"manager": "olu"
},
"lee": {
"manager": "olu"
},
"fay": {
"manager": "olu"
},
"ann": {
"manager": "olu"
},
"raj": {
"manager": "dee"
},
"mia": {
"manager": "dee"
},
"tom": {
"manager": "raj"
},
"kim": {
"manager": "raj"
}
},
"second_level_over": 100000,
"finance_over": 500000,
"finance": "fay",
"fallback": "ann",
"categories": {
"travel": null,
"meals": null,
"tools": null,
"software": "lee"
}
},
[
{
"op": "submit",
"report": "EXP-7101",
"employee": "tom",
"amount": 8640,
"category": "meals"
},
{
"op": "submit",
"report": "EXP-7102",
"employee": "kim",
"amount": 214500,
"category": "tools"
},
{
"op": "submit",
"report": "EXP-7103",
"employee": "raj",
"amount": 380000,
"category": "travel"
},
{
"op": "submit",
"report": "EXP-7104",
"employee": "lee",
"amount": 59900,
"category": "software"
},
{
"op": "approve",
"report": "EXP-7101",
"by": "raj"
},
{
"op": "approve",
"report": "EXP-7102",
"by": "raj"
},
{
"op": "reject",
"report": "EXP-7102",
"by": "dee",
"reason": "Split the torque wrench and the cart into two reports"
},
{
"op": "resubmit",
"report": "EXP-7102",
"by": "kim",
"amount": 96500
},
{
"op": "approve",
"report": "EXP-7103",
"by": "dee"
},
{
"op": "inbox",
"person": "raj"
},
{
"op": "inbox",
"person": "olu"
},
{
"op": "status",
"report": "EXP-7104"
},
{
"op": "log",
"report": "EXP-7102"
}
]
]samples/one-week-expected.json What the spec says that week returns, event by event.[
{"report": "EXP-7101", "state": "pending", "approver": "raj"},
{"report": "EXP-7102", "state": "pending", "approver": "raj"},
{"report": "EXP-7103", "state": "pending", "approver": "dee"},
{"report": "EXP-7104", "state": "pending", "approver": "olu"},
{"report": "EXP-7101", "state": "approved"},
{"report": "EXP-7102", "state": "pending", "approver": "dee"},
{"report": "EXP-7102", "state": "returned", "to": "kim"},
{"report": "EXP-7102", "state": "pending", "approver": "raj"},
{"report": "EXP-7103", "state": "pending", "approver": "olu"},
{"person": "raj", "reports": ["EXP-7102"]},
{"person": "olu", "reports": ["EXP-7103", "EXP-7104"]},
{"report": "EXP-7104", "state": "pending", "chain": ["olu", "ann"], "approver": "olu"},
{"report": "EXP-7102", "state": "pending", "entries": [{"action": "submitted", "by": "kim", "amount": 214500}, {"action": "approved", "by": "raj"}, {"action": "rejected", "by": "dee", "reason": "Split the torque wrench and the cart into two reports"}, {"action": "resubmitted", "by": "kim", "amount": 96500}]}
]reports/audit-finding-2026-14.md The audit finding behind this work, with the January 15 deadline.# Audit finding 2026-14: expense approvals Severity: high. Owner: Finance Systems. Due: 2027-01-15. 1. Report EXP-5530 ($3,800.00, travel) was submitted by a regional manager and approved by the same person. The macro sends each report to the manager field the submitter fills in. 2. 412 reports from August to October waited more than 30 days. 371 of them had been rejected once; the macro has no step for a rejected report, so the reply email was the only record. 3. No single record shows who approved a report and in what order. Required: an approval chain worked out from the org chart and the policy, no self-approval, a clear owner for every open report, and a decision log.
metrics/open-reports-2026-11.csv Reports submitted, approved and returned each week, and how many have waited more than 30 days.week,submitted,approved,returned,open_over_30_days,median_days_to_pay 2026-11-02,2104,1876,141,398,11 2026-11-09,2230,1941,152,405,12 2026-11-16,2187,1902,133,409,12 2026-11-23,2251,1988,160,412,13
TASK-201 Read docs/spec.md and decide the data model Reported by Grace (finance systems)
Expected NOTES.md says what a report holds and how you know who it waits on, and why that is enough for rejections and resubmissions.
Actual Workflow stores reports, but nothing writes down what a decision changes, and the chain and the decisions are stubs.
TASK-202 Core: the approval chain for a report, shown by status Reported by Grace (finance systems)
Expected EXP-7104 from the IT lead has the chain ["olu", "ann"]: his manager, then the fallback in place of himself.
Actual Every submission fails with NotImplementedError: "Implement approval_chain using the request contract".
TASK-203 Then approvals, rejections and resubmission, then the inbox and the log Reported by Hector (accounts payable)
Expected Every result matches the expected file. EXP-7102 is back with raj after the resubmission, and its log has all four entries.
Actual The first approval fails with NotImplementedError: "Implement Workflow.decide using the request contract".
TASK-204 Write down anything you chose to leave out or would do next Reported by Nadia (controller)
Expected A short list of what the engine does not handle yet and what you would build next, with a reason for each.
Actual NOTES.md has no entry.
Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard
Build the engine that routes expense reports for approval. The chain depends on the amount, the category and the org chart, and nobody may approve their own report. The spec is one page. Start with a working core and grow it. Use the AI assistant however you like, and tell me your data model before you ask it for code.