Audit leave balances against the leave policy.
Done by an agent. Checked twice.
Every leave balance rebuilt from the policy and the requests, with each difference from the system listed by size and likely cause.
Real files in
- employees.csv
24 employees with start date, working days and days carried from last year. 25 lines, 1 KB. - leave_policy.md
The company's annual leave policy: entitlement, part time, joiners, rounding, carry over and what uses up leave. 47 lines, 2 KB. - leave_requests.csv
69 leave requests for the year, with a request entered twice, wrong day counts, a name spelled two ways and a request for someone not on the list. 70 lines, 5 KB. - system_balances.csv
The leave balance the HR system shows for each employee, 12 of them wrong. 25 lines, 723 bytes.
Sample data written by Atris. Not a real company.
Three steps
- 1.Read the policy and the records
- 2.Rebuild every balance from the policy
- 3.Write the audit
Claude Sonnet 5.5, 1 min 18 s. No web. It never saw the check.
Checked twice
- Passed: 24 of 24 employees appear once in balance_audit.csv
- Passed: 24 of 24 entitlements and carry over figures equal the figures rebuilt from the policy
- Passed: 24 of 24 days taken figures equal the working days recounted from the approved requests
- Passed: 24 of 24 correct balances and differences from the system equal the rebuilt figures
- Passed: 24 of 24 rows carry the name from employees.csv and the balance from system_balances.csv
- Passed: 24 of 24 rows carry the right status, with 12 system balances wrong and 1 employee overdrawn
- Passed: 149 of 149 dates and figures in findings.md are found in the policy or in the records of the people and requests named on the same line
- Passed: 13 of 13 mismatched or overdrawn employees are named in findings.md and 12 of 12 mismatches show both balances and the difference on one line
- Passed: 7 of 7 problem requests are named in findings.md
Second review by Claude Opus 5.5: pass.
Then we broke a copy of the output 6 ways on purpose. The check caught 6.
| Employee | Correct | System | Difference | Likely cause | |---|---|---|---|---| | E-03 Chidinma Oyelowo-Park | 18 | 16 | -2 | LR-5034 (13 to 19 Jul) was entered as 7 days. Only 5 are working days; the 18th and 19th are a weekend (policy s6). The system likely deducted the 7 entered. | | E-05 Eleni Papadakis-Moor | 18 | 16 | -2 | LR-5014 (1 to 8 Apr) was entered as 6 days. The recount is 4, because 3 Apr and 6 Apr are company holidays (s6). The system likely deducted the 6 entered. | | E-07 Greta Lindholm-Price | 13 | 8 | -5 | LR-5069 duplicates LR-5042 (same dates, 10 to 14 Aug). It should count once (s6), and the system likely deducted both. | | E-09 Ingrid Vasquez-Noor | 16 | 13 | -3 | LR-5029 (15 to 17 Jun, 3 days) is cancelled. Cancelled requests don't use up leave (s6), and the system likely deducted it. | | E-11 Keiko Tanabe-Rhodes | 16 | 14 | -2 | LR-5021 (6 to 7 May, 2 days) is sick leave. Sick leave doesn't use up leave (s6), and the system likely deducted it. | | E-12 Lorcan Devereux | 18 | 21 | +3 | employees.csv shows 8 days carried from 2025. Only 5 may carry over (s5). The system likely carried all 8. | | E-14 Nikolai Petrenko-Gray | 14 | 11 | -3 | Started 2020-11-02, so 5 full years of service on 1 Jan 2026. That gives 28 days (s1). The system likely used 25. The files show no request that explains the 3 days. | | E-16 Pavel Dvorak-Stone | 12 | 18 | +6 | Joined 2026-03-16. Entitlement should be 25 x 9/12 = 18.75, rounded up to 19 (s3, s4). The system likely gave the full 25 (25 - 7 = 18). | | E-18 Rahima Chowdhury-Vale | 8 | 6 | -2 | LR-5024 (18 to 22 May) was entered as 5 days. This person works Mon to Wed, so the recount is 3 (s2, s6). The system likely deducted 5. | | E-19 Seren Bowen-Aziz | 10.5 | 10.4 | -0.1 | Part-time entitlement is 28 x 4/5 = 22.4, rounded up to 22.5 (s2, s4). The system likely kept 22.4 (22.4 - 12 = 10.4). | | E-21 Ursula Engstrom-Kay | 22.5 | 22 | -0.5 | LR-5028 (12 Jun) is a half day but was entered as 1. It should count 0.5 (s6). The system likely deducted 1. | | E-23 Wendell Osei-Hartley | 26 | 23 | -3 | LR-5068 (29 Dec 2026 to 5 Jan 2027) was entered as 6 days. Only 29, 30 and 31 Dec count, because days in 2027 belong to next year (s6). 28 Dec is a company holiday. The system likely deducted the 6 entered. |
How this was run
An AI agent on Claude Sonnet 5.5 was given a folder with the files below and a three-step flow, and nothing else. It had no web access and never saw the check. The check was written before the run and made stricter after it. It works the answer out again from the input files. Then Claude Opus 5.5 reviewed the result against the inputs. The input files are sample data written by Atris, with the problems a real week has planted in them.
Run 1 of 1 on 1 December 2026. The agent took 1 min 18 s.
What the second review verified
- Rebuilt all 24 rows in python3 from the policy and requests. Every entitlement, carry-over, days_taken, correct_balance, difference, status and overdrawn value matches balance_audit.csv, e.g. E-16 is 25×9/12=18.75, rounded up to 19, minus 7 days, for a balance of 12; E-19 is 28×4/5=22.4, rounded up to 22.5, for 10.5
- My recount gives the same five days_entered differences: LR-5014 (6 entered, 4 recounted), LR-5024 (5 vs 3), LR-5028 (1 vs 0.5), LR-5034 (7 vs 5) and LR-5068 (6 vs 3). It also finds the same duplicate, LR-5069 repeating LR-5042, and the same unknown-employee request, LR-5009 for E-31
- Each mismatch cause gives the exact difference: E-07's duplicate adds 5 days, so 13-5=8; E-12 carried all 8 days instead of 5, so 18+3=21; E-14 used 25 instead of 28 days, so 25+1-15=11; E-11's sick leave adds 2 days, so 16-2=14
- There are 12 right and 12 wrong balances, and E-20 is the only person overdrawn, at -2 (25 days owed, 27 taken from LR-5002, LR-5015, LR-5045 and LR-5062)
What this run does not show
- The likely cause given for each wrong balance is read only by the second review, because the files do not show how the system worked each balance out.
- Figures in the findings are matched to the people and requests named on the same line, so a small number swapped for another from that person's records can slip through.
- The policy and records were written for this run, with one clear cause behind each wrong balance.
Would the check catch a wrong answer?
A check that cannot fail proves nothing. After the run we took a copy of the output, broke it one small way at a time and ran the check again. It caught 6 of 6. The check was made stricter after the first try at this, and the same untouched output was graded again.
Open every file
flow.md · the three steps the agent followed
# Audit leave balances against the leave policy function: people for: the people manager who signs off leave balances goal: Every employee's leave balance is rebuilt from the policy and the leave requests so that every difference from the system's figure is listed with its size and likely cause. ## 1. Read the policy and the records Read input/leave_policy.md, input/employees.csv, input/leave_requests.csv and input/system_balances.csv. Match people on employee_id, never on how a name is spelled. Note the leave year, the company holidays and each rule that changes what a person is owed or what uses up leave. ## 2. Rebuild every balance from the policy For each employee in employees.csv work out, by the policy: - entitlement for this leave year - carry_over_allowed - days_taken: recount the days of every request from its dates. Never trust days_entered. - correct_balance = entitlement + carry_over_allowed - days_taken - difference = system_balance - correct_balance status is `ok` when the difference is zero, otherwise `mismatch`. overdrawn is `yes` when correct_balance is below zero, otherwise `no`. Do all date counting and sums in python3, not in your head. ## 3. Write the audit Write output/balance_audit.csv with columns employee_id,name,entitlement,carry_over_allowed,days_taken,correct_balance,system_balance,difference,status,overdrawn. One row per employee, names as in employees.csv. Write output/findings.md for the people manager: - how many balances are right and how many are wrong - one line per mismatch: employee_id, both balances, the difference and the most likely cause, naming the request_id or the policy section behind it. Say "likely" unless the files prove it. - request problems, each by request_id: a request that uses up leave whose days_entered differs from your recount, a request entered twice (name the later request_id), a request for someone not in employees.csv - anyone overdrawn ## Done looks like - Every employee has one row and every figure in it can be rebuilt from the policy and the requests. - Every mismatch and every request problem is listed in findings.md.
input/employees.csv · 25 lines, 1 KB
employee_id,name,start_date,working_days,carried_from_2025 E-01,Abigail Thornbury,2015-04-13,Mon Tue Wed Thu Fri,3 E-02,Benedikt Sorensen-Hale,2022-09-05,Mon Tue Wed Thu Fri,0 E-03,Chidinma Oyelowo-Park,2019-01-07,Mon Tue Wed Thu Fri,5 E-04,Darragh Fitzwilliam,2023-05-15,Mon Tue Wed Thu Fri,2 E-05,Eleni Papadakis-Moor,2017-03-01,Mon Tue Wed Thu Fri,4 E-06,Farouk Benhaddou,2024-02-12,Mon Tue Wed Thu Fri,1 E-07,Greta Lindholm-Price,2016-08-22,Mon Tue Wed Thu Fri,0 E-08,Hamish Abernathy-Cole,2021-06-07,Mon Tue Wed Thu Fri,5 E-09,Ingrid Vasquez-Noor,2018-10-01,Mon Tue Wed Thu Fri,2 E-10,Jomo Kariuki-Wells,2025-01-13,Mon Tue Wed Thu Fri,0 E-11,Keiko Tanabe-Rhodes,2020-02-03,Mon Tue Wed Thu Fri,3 E-12,Lorcan Devereux,2014-11-17,Mon Tue Wed Thu Fri,8 E-13,Mirembe Nakato-Shaw,2023-01-09,Mon Tue Wed Thu Fri,0 E-14,Nikolai Petrenko-Gray,2020-11-02,Mon Tue Wed Thu Fri,1 E-15,Ottilie Ravensworth,2021-01-04,Mon Tue Wed Thu Fri,0 E-16,Pavel Dvorak-Stone,2026-03-16,Mon Tue Wed Thu Fri,0 E-17,Quentin Ashdown-Li,2026-06-01,Mon Tue Wed Thu Fri,0 E-18,Rahima Chowdhury-Vale,2022-04-04,Mon Tue Wed,2 E-19,Seren Bowen-Aziz,2018-02-19,Mon Tue Wed Thu,0 E-20,Tadeusz Markiewicz,2024-09-02,Mon Tue Wed Thu Fri,0 E-21,Ursula Engstrom-Kay,2019-07-15,Mon Tue Wed Thu Fri,4 E-22,Katarzyna Wojcik-Bell,2022-11-28,Mon Tue Wed Thu Fri,1 E-23,Wendell Osei-Hartley,2016-01-11,Mon Tue Wed Thu Fri,5 E-24,Xanthe Mulroney,2025-08-18,Mon Tue Wed Thu Fri,0
input/leave_policy.md · 47 lines, 2 KB
# Annual leave policy: Ellingham Reed Surveyors Leave year: 1 January 2026 to 31 December 2026. ## 1. Yearly entitlement A full-time employee gets 25 days of annual leave a year. An employee with 5 or more full years of service on 1 January 2026 gets 28 days. ## 2. Part time A part-time employee gets the yearly entitlement multiplied by the number of days they work each week and divided by 5. The employee list gives each person's working days. ## 3. People who join during the year Someone who joins during the leave year gets one twelfth of their yearly entitlement for each full calendar month left in the year. The month they join counts only when they start on the 1st. ## 4. Rounding After sections 1 to 3, round the entitlement up to the next half day. An entitlement that is already a whole or half day stays as it is. ## 5. Carry over Up to 5 unused days from 2025 may be carried into 2026. Anything above 5 is lost. ## 6. What uses up leave - Only annual leave with the status approved uses up the balance. Sick leave, unpaid leave and requests that are pending, declined or cancelled do not. - Count each day from the first day to the last day of the request that is one of the employee's own working days and is not a company holiday. - A request marked as a half day counts as 0.5. - Approved leave booked for later in the leave year counts now. - Days after 31 December 2026 belong to next year and do not count. - Two requests for the same employee with the same type, first day and last day are one request entered twice. Count it once. ## 7. Balance Balance = entitlement + carry over allowed - days that use up leave. Nobody should go below zero. ## Company holidays in 2026 2026-01-01, 2026-04-03, 2026-04-06, 2026-05-04, 2026-05-25, 2026-08-31, 2026-12-25, 2026-12-28
input/leave_requests.csv · 70 lines, 5 KB
request_id,employee_id,employee_name,leave_type,first_day,last_day,half_day,days_entered,status LR-5001,E-08,Hamish Abernathy-Cole,annual,2026-01-05,2026-01-09,no,5,approved LR-5002,E-20,Tadeusz Markiewicz,annual,2026-01-19,2026-01-30,no,10,approved LR-5003,E-02,Benedikt Sorensen-Hale,sick,2026-01-20,2026-01-21,no,2,approved LR-5004,E-22,Katarzyna Wojick-Bell,annual,2026-02-02,2026-02-06,no,5,approved LR-5005,E-06,Farouk Benhaddou,annual,2026-02-09,2026-02-13,no,5,approved LR-5006,E-01,Abigail Thornbury,annual,2026-02-16,2026-02-20,no,5,approved LR-5007,E-11,Keiko Tanabe-Rhodes,annual,2026-02-23,2026-02-27,no,5,approved LR-5008,E-10,Jomo Kariuki-Wells,annual,2026-03-02,2026-03-06,no,5,approved LR-5009,E-31,Leopold Varga-Nunn,annual,2026-03-02,2026-03-06,no,5,approved LR-5010,E-02,Benedikt Sorensen-Hale,annual,2026-03-09,2026-03-13,no,5,approved LR-5011,E-14,Nikolai Petrenko-Gray,annual,2026-03-16,2026-03-20,no,5,approved LR-5012,E-07,Greta Lindholm-Price,annual,2026-03-23,2026-03-27,no,5,approved LR-5013,E-21,Ursula Engstrom-Kay,annual,2026-03-30,2026-04-02,no,4,approved LR-5014,E-05,Eleni Papadakis-Moor,annual,2026-04-01,2026-04-08,no,6,approved LR-5015,E-20,Tadeusz Markiewicz,annual,2026-04-07,2026-04-17,no,9,approved LR-5016,E-03,Chidinma Oyelowo-Park,annual,2026-04-13,2026-04-17,no,5,approved LR-5017,E-19,Seren Bowen-Aziz,annual,2026-04-13,2026-04-16,no,4,approved LR-5018,E-09,Ingrid Vasquez-Noor,annual,2026-04-20,2026-04-24,no,5,approved LR-5019,E-13,Mirembe Nakato-Shaw,annual,2026-04-27,2026-05-01,no,5,approved LR-5020,E-23,Wendell Osei-Hartley,annual,2026-05-05,2026-05-08,no,4,approved LR-5021,E-11,Keiko Tanabe-Rhodes,sick,2026-05-06,2026-05-07,no,2,approved LR-5022,E-08,Hamish Abernathy-Cole,annual,2026-05-11,2026-05-15,no,5,approved LR-5023,E-15,Ottilie Ravensworth,annual,2026-05-18,2026-05-22,no,5,approved LR-5024,E-18,Rahima Chowdhury-Vale,annual,2026-05-18,2026-05-22,no,5,approved LR-5025,E-04,Darragh Fitzwilliam,annual,2026-05-26,2026-05-29,no,4,approved LR-5026,E-01,Abigail Thornbury,annual,2026-06-01,2026-06-05,no,5,approved LR-5027,E-12,Lorcan Devereux,annual,2026-06-08,2026-06-19,no,10,approved LR-5028,E-21,Ursula Engstrom-Kay,annual,2026-06-12,2026-06-12,yes,1,approved LR-5029,E-09,Ingrid Vasquez-Noor,annual,2026-06-15,2026-06-17,no,3,cancelled LR-5030,E-06,Farouk Benhaddou,annual,2026-06-22,2026-06-26,no,5,approved LR-5031,E-22,Katarzyna Wojick-Bell,annual,2026-06-29,2026-07-03,no,5,approved LR-5032,E-08,Hamish Abernathy-Cole,annual,2026-07-06,2026-07-17,no,10,approved LR-5033,E-15,Ottilie Ravensworth,annual,2026-07-06,2026-07-10,no,5,approved LR-5034,E-03,Chidinma Oyelowo-Park,annual,2026-07-13,2026-07-19,no,7,approved LR-5035,E-24,Xanthe Mulroney,annual,2026-07-13,2026-07-24,no,10,approved LR-5036,E-11,Keiko Tanabe-Rhodes,annual,2026-07-20,2026-07-31,no,10,approved LR-5037,E-02,Benedikt Sorensen-Hale,annual,2026-07-27,2026-08-07,no,10,approved LR-5038,E-19,Seren Bowen-Aziz,annual,2026-07-27,2026-08-06,no,8,approved LR-5039,E-24,Xanthe Mulroney,unpaid,2026-07-27,2026-07-31,no,5,approved LR-5040,E-05,Eleni Papadakis-Moor,annual,2026-08-03,2026-08-14,no,10,approved LR-5041,E-16,Pavel Dvorak-Stone,annual,2026-08-03,2026-08-07,no,5,approved LR-5042,E-07,Greta Lindholm-Price,annual,2026-08-10,2026-08-14,no,5,approved LR-5043,E-18,Rahima Chowdhury-Vale,annual,2026-08-10,2026-08-12,no,3,approved LR-5044,E-01,Abigail Thornbury,annual,2026-08-17,2026-08-28,no,10,approved LR-5045,E-20,Tadeusz Markiewicz,annual,2026-08-17,2026-08-21,no,5,approved LR-5046,E-10,Jomo Kariuki-Wells,annual,2026-08-24,2026-08-28,no,5,approved LR-5047,E-13,Mirembe Nakato-Shaw,annual,2026-08-31,2026-09-04,no,4,approved LR-5048,E-09,Ingrid Vasquez-Noor,annual,2026-09-01,2026-09-11,no,9,approved LR-5049,E-04,Darragh Fitzwilliam,annual,2026-09-07,2026-09-18,no,10,approved LR-5050,E-21,Ursula Engstrom-Kay,annual,2026-09-07,2026-09-11,no,5,approved LR-5051,E-14,Nikolai Petrenko-Gray,annual,2026-09-14,2026-09-25,no,10,approved LR-5052,E-06,Farouk Benhaddou,annual,2026-09-21,2026-09-25,no,5,approved LR-5053,E-17,Quentin Ashdown-Li,annual,2026-09-28,2026-10-02,no,5,approved LR-5054,E-12,Lorcan Devereux,annual,2026-10-05,2026-10-09,no,5,approved LR-5055,E-22,Katarzyna Wojcik-Bell,annual,2026-10-09,2026-10-09,yes,0.5,approved LR-5056,E-07,Greta Lindholm-Price,annual,2026-10-12,2026-10-16,no,5,approved LR-5057,E-15,Ottilie Ravensworth,annual,2026-10-19,2026-10-23,no,5,approved LR-5058,E-02,Benedikt Sorensen-Hale,annual,2026-10-26,2026-10-30,no,5,approved LR-5059,E-18,Rahima Chowdhury-Vale,annual,2026-10-26,2026-10-28,no,3,approved LR-5060,E-03,Chidinma Oyelowo-Park,annual,2026-11-02,2026-11-06,no,5,approved LR-5061,E-16,Pavel Dvorak-Stone,annual,2026-11-09,2026-11-10,no,2,approved LR-5062,E-20,Tadeusz Markiewicz,annual,2026-11-16,2026-11-18,no,3,approved LR-5063,E-10,Jomo Kariuki-Wells,annual,2026-11-23,2026-11-27,no,5,approved LR-5064,E-06,Farouk Benhaddou,annual,2026-12-01,2026-12-11,no,9,declined LR-5065,E-13,Mirembe Nakato-Shaw,annual,2026-12-07,2026-12-11,no,5,approved LR-5066,E-04,Darragh Fitzwilliam,annual,2026-12-14,2026-12-18,no,5,pending LR-5067,E-01,Abigail Thornbury,annual,2026-12-21,2026-12-24,no,4,approved LR-5068,E-23,Wendell Osei-Hartley,annual,2026-12-29,2027-01-05,no,6,approved LR-5069,E-07,Greta Lindholm-Price,annual,2026-08-10,2026-08-14,no,5,approved
input/system_balances.csv · 25 lines, 723 bytes
employee_id,name,balance_days E-01,Abigail Thornbury,7 E-02,Benedikt Sorensen-Hale,5 E-03,Chidinma Oyelowo-Park,16 E-04,Darragh Fitzwilliam,13 E-05,Eleni Papadakis-Moor,16 E-06,Farouk Benhaddou,11 E-07,Greta Lindholm-Price,8 E-08,Hamish Abernathy-Cole,10 E-09,Ingrid Vasquez-Noor,13 E-10,Jomo Kariuki-Wells,10 E-11,Keiko Tanabe-Rhodes,14 E-12,Lorcan Devereux,21 E-13,Mirembe Nakato-Shaw,11 E-14,Nikolai Petrenko-Gray,11 E-15,Ottilie Ravensworth,10 E-16,Pavel Dvorak-Stone,18 E-17,Quentin Ashdown-Li,10 E-18,Rahima Chowdhury-Vale,6 E-19,Seren Bowen-Aziz,10.4 E-20,Tadeusz Markiewicz,-2 E-21,Ursula Engstrom-Kay,22 E-22,Katarzyna Wojcik-Bell,15.5 E-23,Wendell Osei-Hartley,23 E-24,Xanthe Mulroney,15
output/balance_audit.csv · written by the agent, 25 lines
employee_id,name,entitlement,carry_over_allowed,days_taken,correct_balance,system_balance,difference,status,overdrawn E-01,Abigail Thornbury,28,3,24,7,7,0,ok,no E-02,Benedikt Sorensen-Hale,25,0,20,5,5,0,ok,no E-03,Chidinma Oyelowo-Park,28,5,15,18,16,-2,mismatch,no E-04,Darragh Fitzwilliam,25,2,14,13,13,0,ok,no E-05,Eleni Papadakis-Moor,28,4,14,18,16,-2,mismatch,no E-06,Farouk Benhaddou,25,1,15,11,11,0,ok,no E-07,Greta Lindholm-Price,28,0,15,13,8,-5,mismatch,no E-08,Hamish Abernathy-Cole,25,5,20,10,10,0,ok,no E-09,Ingrid Vasquez-Noor,28,2,14,16,13,-3,mismatch,no E-10,Jomo Kariuki-Wells,25,0,15,10,10,0,ok,no E-11,Keiko Tanabe-Rhodes,28,3,15,16,14,-2,mismatch,no E-12,Lorcan Devereux,28,5,15,18,21,3,mismatch,no E-13,Mirembe Nakato-Shaw,25,0,14,11,11,0,ok,no E-14,Nikolai Petrenko-Gray,28,1,15,14,11,-3,mismatch,no E-15,Ottilie Ravensworth,25,0,15,10,10,0,ok,no E-16,Pavel Dvorak-Stone,19,0,7,12,18,6,mismatch,no E-17,Quentin Ashdown-Li,15,0,5,10,10,0,ok,no E-18,Rahima Chowdhury-Vale,15,2,9,8,6,-2,mismatch,no E-19,Seren Bowen-Aziz,22.5,0,12,10.5,10.4,-0.1,mismatch,no E-20,Tadeusz Markiewicz,25,0,27,-2,-2,0,ok,yes E-21,Ursula Engstrom-Kay,28,4,9.5,22.5,22,-0.5,mismatch,no E-22,Katarzyna Wojcik-Bell,25,1,10.5,15.5,15.5,0,ok,no E-23,Wendell Osei-Hartley,28,5,7,26,23,-3,mismatch,no E-24,Xanthe Mulroney,25,0,10,15,15,0,ok,no
output/findings.md · written by the agent, 58 lines
# Leave balance audit, leave year 2026 Rebuilt from input/leave_policy.md, employees.csv and leave_requests.csv, then compared with system_balances.csv. Full figures are in balance_audit.csv. People are matched on employee_id. ## Result - 24 employees checked: **12 balances are right, 12 are wrong.** - Right: E-01, E-02, E-04, E-06, E-08, E-10, E-13, E-15, E-17, E-20, E-22, E-24. - Wrong: E-03, E-05, E-07, E-09, E-11, E-12, E-14, E-16, E-18, E-19, E-21, E-23. ## Mismatches Difference = system balance minus correct balance. A negative difference means the system shows less leave than the person is owed. The causes below are "likely". The size of each difference matches the cause named, but the files don't show how the system worked it out. | Employee | Correct | System | Difference | Likely cause | |---|---|---|---|---| | E-03 Chidinma Oyelowo-Park | 18 | 16 | -2 | LR-5034 (13 to 19 Jul) was entered as 7 days. Only 5 are working days; the 18th and 19th are a weekend (policy s6). The system likely deducted the 7 entered. | | E-05 Eleni Papadakis-Moor | 18 | 16 | -2 | LR-5014 (1 to 8 Apr) was entered as 6 days. The recount is 4, because 3 Apr and 6 Apr are company holidays (s6). The system likely deducted the 6 entered. | | E-07 Greta Lindholm-Price | 13 | 8 | -5 | LR-5069 duplicates LR-5042 (same dates, 10 to 14 Aug). It should count once (s6), and the system likely deducted both. | | E-09 Ingrid Vasquez-Noor | 16 | 13 | -3 | LR-5029 (15 to 17 Jun, 3 days) is cancelled. Cancelled requests don't use up leave (s6), and the system likely deducted it. | | E-11 Keiko Tanabe-Rhodes | 16 | 14 | -2 | LR-5021 (6 to 7 May, 2 days) is sick leave. Sick leave doesn't use up leave (s6), and the system likely deducted it. | | E-12 Lorcan Devereux | 18 | 21 | +3 | employees.csv shows 8 days carried from 2025. Only 5 may carry over (s5). The system likely carried all 8. | | E-14 Nikolai Petrenko-Gray | 14 | 11 | -3 | Started 2020-11-02, so 5 full years of service on 1 Jan 2026. That gives 28 days (s1). The system likely used 25. The files show no request that explains the 3 days. | | E-16 Pavel Dvorak-Stone | 12 | 18 | +6 | Joined 2026-03-16. Entitlement should be 25 x 9/12 = 18.75, rounded up to 19 (s3, s4). The system likely gave the full 25 (25 - 7 = 18). | | E-18 Rahima Chowdhury-Vale | 8 | 6 | -2 | LR-5024 (18 to 22 May) was entered as 5 days. This person works Mon to Wed, so the recount is 3 (s2, s6). The system likely deducted 5. | | E-19 Seren Bowen-Aziz | 10.5 | 10.4 | -0.1 | Part-time entitlement is 28 x 4/5 = 22.4, rounded up to 22.5 (s2, s4). The system likely kept 22.4 (22.4 - 12 = 10.4). | | E-21 Ursula Engstrom-Kay | 22.5 | 22 | -0.5 | LR-5028 (12 Jun) is a half day but was entered as 1. It should count 0.5 (s6). The system likely deducted 1. | | E-23 Wendell Osei-Hartley | 26 | 23 | -3 | LR-5068 (29 Dec 2026 to 5 Jan 2027) was entered as 6 days. Only 29, 30 and 31 Dec count, because days in 2027 belong to next year (s6). 28 Dec is a company holiday. The system likely deducted the 6 entered. | ## Request problems Days entered that differ from the recount (requests that use up leave): - LR-5014 (E-05): entered 6, recount 4. - LR-5024 (E-18): entered 5, recount 3. - LR-5028 (E-21): entered 1, recount 0.5. - LR-5034 (E-03): entered 7, recount 5. - LR-5068 (E-23): entered 6, recount 3. Entered twice: - **LR-5069** (E-07) is the later entry. It repeats LR-5042 (annual, 2026-08-10 to 2026-08-14). Request for someone not in employees.csv: - LR-5009: employee E-31, "Leopold Varga-Nunn", annual, 2 to 6 Mar 2026, approved, 5 days. E-31 is not in employees.csv or system_balances.csv, so nothing is counted. The files don't say who this person is. Other things I noticed, which don't change any figure: - LR-5004 and LR-5031 spell E-22's name "Wojick-Bell". employees.csv has "Wojcik-Bell". They were matched on E-22, and E-22's balance is right. ## Overdrawn - **E-20 Tadeusz Markiewicz** is overdrawn. Correct balance is -2 (25 entitlement + 0 carry over - 27 days taken). The system also shows -2. The policy says nobody should go below zero (s7), so these approved requests need a decision. The 27 days come from LR-5002 (10), LR-5015 (9), LR-5045 (5) and LR-5062 (3). - Nobody else is overdrawn. ## Assumptions and gaps - Years of service are counted as full years from the start date to 1 Jan 2026. E-11 (started 2020-02-03) and E-14 (2020-11-02) reach 5 years and get 28 days. E-08 (2021-06-07) and E-15 (2021-01-04) have under 5 years and get 25. - The policy doesn't say whether carry over is prorated for part-timers. I did not prorate it (E-18 carries 2 days, E-19 carries 0). - The policy doesn't cover a half day that falls on a non-working day or a company holiday. No request is affected. - Approved leave later in the year (up to 31 Dec) counts now, as s6 says. Pending LR-5066 and declined LR-5064 do not count. Unpaid LR-5039 and sick LR-5003 and LR-5021 do not count.
check.py · the check, written before the run
"""Rebuilds every leave balance from the policy and the requests, then compares with the audit."""
import csv, re, sys
from datetime import date, timedelta
from fractions import Fraction as F
from pathlib import Path
root = Path(sys.argv[1]); ok = True
def say(passed, text):
global ok; ok = ok and passed; print(("PASS " if passed else "FAIL ") + text)
def norm(s): return " ".join((s or "").split())
def num(s):
try: return F(norm(s))
except (ValueError, ZeroDivisionError): return None
def same(a, b): return a is not None and abs(a - b) < F(1, 200)
pol = (root/"input/leave_policy.md").read_text()
YEAR = int(re.search(r"Leave year: .*?(\d{4})", pol).group(1))
hol = set(re.findall(r"\d{4}-\d{2}-\d{2}", pol.split("## Company holidays")[1]))
base_days = int(re.search(r"gets (\d+) days of annual leave", pol).group(1)); long_days = int(re.search(r"gets (\d+) days\.", pol).group(1))
long_years = int(re.search(r"with (\d+) or more full years", pol).group(1)); cap = int(re.search(r"Up to (\d+) unused days", pol).group(1))
DN = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
emps = {r["employee_id"]: r for r in csv.DictReader((root/"input/employees.csv").open())}
reqs = list(csv.DictReader((root/"input/leave_requests.csv").open()))
sysb = {r["employee_id"]: F(r["balance_days"]) for r in csv.DictReader((root/"input/system_balances.csv").open())}
def days(r, wd):
if r["half_day"].strip().lower() == "yes": return F(1, 2)
d, end, n = date.fromisoformat(r["first_day"]), date.fromisoformat(r["last_day"]), 0
while d <= end:
n += d.year == YEAR and DN[d.weekday()] in wd and d.isoformat() not in hol
d += timedelta(days=1)
return F(n)
want, req_problem = {}, set()
for eid, e in emps.items():
sd = date.fromisoformat(e["start_date"]); wd = e["working_days"].split()
served = YEAR - sd.year - (0 if (sd.month, sd.day) == (1, 1) else 1)
ent = F(long_days if served >= long_years else base_days) * len(wd) / 5
if sd.year == YEAR: ent = ent * (12 - sd.month + (1 if sd.day == 1 else 0)) / 12
raw = ent; ent = F(-((-ent * 2) // 1), 2)
carry = min(F(e["carried_from_2025"]), cap); taken, seen = F(0), set()
for r in sorted((r for r in reqs if r["employee_id"] == eid), key=lambda r: r["request_id"]):
if r["leave_type"] != "annual" or r["status"] != "approved": continue
key = (r["first_day"], r["last_day"])
if key in seen: req_problem.add(r["request_id"]); continue
seen.add(key); n = days(r, wd); taken += n
if F(r["days_entered"]) != n: req_problem.add(r["request_id"])
bal = ent + carry - taken
want[eid] = {"ent": ent, "carry": carry, "taken": taken, "bal": bal, "diff": sysb[eid] - bal, "sys": sysb[eid], "name": e["name"],
"work": {raw, F(long_days if served >= long_years else base_days), F(len(wd)), F(5), F(12), F(12 - sd.month + (1 if sd.day == 1 else 0)), F(max(served, 0)),
F(e["carried_from_2025"]), F(cap), F(long_years), F(base_days), F(long_days), F(sd.year)}}
req_problem |= {r["request_id"] for r in reqs if r["employee_id"] not in emps}
path = root/"output/balance_audit.csv"
if not path.exists():
say(False, "output/balance_audit.csv was not written"); sys.exit(1)
rows = list(csv.DictReader(path.open())); got = {}
for r in rows: got.setdefault(norm(r.get("employee_id")), []).append(r)
g = {k: got[k][0] for k in want if len(got.get(k, [])) == 1}; n = len(want)
say(len(g) == n and len(rows) == n, f"{len(g)} of {n} employees appear once in balance_audit.csv")
ent = sum(1 for k, w in want.items() if k in g and same(num(g[k].get("entitlement")), w["ent"]) and same(num(g[k].get("carry_over_allowed")), w["carry"]))
say(ent == n, f"{ent} of {n} entitlements and carry over figures equal the figures rebuilt from the policy")
tk = sum(1 for k, w in want.items() if k in g and same(num(g[k].get("days_taken")), w["taken"]))
say(tk == n, f"{tk} of {n} days taken figures equal the working days recounted from the approved requests")
bal = sum(1 for k, w in want.items() if k in g and same(num(g[k].get("correct_balance")), w["bal"]) and same(num(g[k].get("difference")), w["diff"]))
say(bal == n, f"{bal} of {n} correct balances and differences from the system equal the rebuilt figures")
wrong = [k for k, w in want.items() if w["diff"] != 0]; over = [k for k, w in want.items() if w["bal"] < 0]
st = sum(1 for k, w in want.items() if k in g and norm(g[k].get("status")).lower() == ("mismatch" if w["diff"] != 0 else "ok") and norm(g[k].get("overdrawn")).lower() == ("yes" if w["bal"] < 0 else "no"))
idn = sum(1 for k, w in want.items() if k in g and norm(g[k].get("name")) == norm(w["name"]) and same(num(g[k].get("system_balance")), w["sys"]))
say(idn == n, f"{idn} of {n} rows carry the name from employees.csv and the balance from system_balances.csv")
say(st == n, f"{st} of {n} rows carry the right status, with {len(wrong)} system balances wrong and {len(over)} employee overdrawn")
fnd = (root/"output/findings.md").read_text() if (root/"output/findings.md").exists() else ""
def has(x): return re.search(re.escape(x) + r"\b", fnd) is not None
# every date and figure in findings.md is traced to the people and requests named on its line
NUM = r"(?<![A-Za-z0-9.])(?<![A-Za-z0-9]-)(?:\d{4}-\d{2}-\d{2}|\d+(?:\.\d+)?)(?![A-RT-Za-rt-z\d])"
def toks(text): return re.findall(NUM, text)
def req_facts(r, wd):
out, isos = {F(r["days_entered"])}, {r["first_day"], r["last_day"]}
if wd is not None: out.add(days(r, wd))
d, end = date.fromisoformat(r["first_day"]), date.fromisoformat(r["last_day"])
while d <= end: out |= {F(d.day), F(d.year)}; d += timedelta(days=1)
return out, isos
by_req = {r["request_id"]: req_facts(r, emps[r["employee_id"]]["working_days"].split() if r["employee_id"] in emps else None) for r in reqs}
by_emp = {}
for eid, w in want.items():
nums_ = {w["ent"], w["carry"], w["taken"], w["bal"], w["sys"], w["diff"], abs(w["bal"]), abs(w["diff"])} | w["work"]; isos = {emps[eid]["start_date"]}
for r in reqs:
if r["employee_id"] == eid: nums_ |= by_req[r["request_id"]][0]; isos |= by_req[r["request_id"]][1]
by_emp[eid] = (nums_, isos)
gen_iso = set(re.findall(r"\d{4}-\d{2}-\d{2}", pol))
general = {F(x) for x in toks(pol) if "-" not in x} | {F(int(h[8:])) for h in hol} | {F(x) for x in (n, len(wrong), n - len(wrong), len(over), len(req_problem), len(reqs), YEAR, YEAR - 1, YEAR + 1, len(hol))}
fa = fo = 0; shown = set()
for ln in fnd.split("\n"):
es = [e for e in want if re.search(re.escape(e) + r"\b", ln)]; rs = [r for r in by_req if re.search(re.escape(r) + r"\b", ln)]
allowed, isos = set(general), set(gen_iso)
for e in es: allowed |= by_emp[e][0]; isos |= by_emp[e][1]
for r in rs: allowed |= by_req[r][0]; isos |= by_req[r][1]
seen_here = set()
for t in toks(ln):
fa += 1
if "-" in t: fo += t in isos
else: v = F(t); seen_here.add(v); fo += any(same(v, a) for a in allowed)
for e in es:
w = want[e]
if len(es) == 1 and all(any(same(x, v) for v in seen_here) for x in (abs(w["bal"]), abs(w["sys"]), abs(w["diff"]))): shown.add(e)
say(fo == fa and fa > 0, f"{fo} of {fa} dates and figures in findings.md are found in the policy or in the records of the people and requests named on the same line")
m = sum(1 for k in wrong + over if has(k)); sh = sum(1 for k in wrong if k in shown)
say(m == len(wrong + over) and sh == len(wrong), f"{m} of {len(wrong + over)} mismatched or overdrawn employees are named in findings.md and {sh} of {len(wrong)} mismatches show both balances and the difference on one line")
q = sum(1 for x in req_problem if has(x))
say(q == len(req_problem) and len(req_problem) > 0, f"{q} of {len(req_problem)} problem requests are named in findings.md")
sys.exit(0 if ok else 1)
employees.csv: sample data written by Atris. Fingerprint 7ff089dea116.
leave_policy.md: sample data written by Atris. Fingerprint 558dc960b877.
leave_requests.csv: sample data written by Atris. Fingerprint 71240520fb45.
system_balances.csv: sample data written by Atris. Fingerprint a37008dcae90.
balance_audit.csv: written by the agent. Fingerprint 1e216fe75408.
findings.md: written by the agent. Fingerprint 8374d13dc393.