Atris

Audit the device list against staff.
Done by an agent. Checked twice.

Four checks on every device, with devices held by leavers, missing devices and expired warranties listed by asset tag.

Have Atris do this for you›

1

Real files in

  • audit_rules.md
    The written audit rules: audit date, the 30 day missing rule, how spares and retired devices are treated and one laptop per person. 13 lines, 848 bytes.
  • devices.csv
    51 laptops, phones and tablets from the device list, with leavers still holding devices, a serial typed twice, blank fields and names in place of emails. 52 lines, 5 KB.
  • staff.csv
    Staff list of 34 people, five of them leavers and one with a leaving date still ahead. 35 lines, 3 KB.

Sample data written by Atris. Not a real company.

2

Three steps

  1. 1.Read the lists and the rules
  2. 2.Run four checks on every device
  3. 3.Write the audit

Claude Sonnet 5.5, 44 seconds. No web. It never saw the check.

3

Checked twice

  • ✓Passed: 51 of 51 devices appear once in device_audit.csv
  • ✓Passed: 51 of 51 owner checks equal the result recomputed from the staff list
  • ✓Passed: 51 of 51 check-in results equal the result recomputed from the last seen dates
  • ✓Passed: 51 of 51 devices have the right warranty result, serial result and needs action flag
  • ✓Passed: 4 of 4 people without exactly one laptop are in staff_laptops.csv with the right name and count and 0 people are listed by mistake
  • ✓Passed: 51 of 51 reasons fit the device: 24 name the facts behind what is wrong, with no date, day count, serial or person from another device, and 27 name no problem
  • ✓Passed: 10 of 10 counts in summary.md equal the recomputed counts and 6 of 6 devices held by leavers are named with the person and end date
  • ✓Passed: summary.md lists 6 of 6 missing devices with their last check-in and 4 of 4 people without exactly one laptop with their laptop count
  • ✓Passed: 24 of 24 dates and numbers in summary.md match the device list, the staff list or the recomputed counts

Second review by Claude Opus 5.5: pass.

Then we broke a copy of the output 9 ways on purpose. The check caught 9.

What it wrote. Lines 30 to 40 of summary.md, copied from the file.
## People without exactly one laptop
- E108 Kwabena Rothwell: 2 laptops (more_than_one)
- E116 Mateo Grunewald: 2 laptops (more_than_one)
- E125 Ignatius Thornbury: 0 laptops (no_laptop)
- E127 Gideon Farrow: 0 laptops (no_laptop)

## Devices with no matching owner
- LT-028: Assigned to 'Iggy Thornbury', who is not on the staff list; most likely Ignatius Thornbury (E125). Warranty ended 2026-06-01.
- LT-038: It is in use but has nobody assigned.
- LT-039: Assigned to 'j.merrow@brightquill.example', who is not on the staff list; no staff member is a likely match. Last check-in was 2026-10-28, 33 days before the audit (limit 30).
- TB-03: It is in use but has nobody assigned. Last check-in was 2026-09-14, 77 days before the audit (limit 30). Warranty ended 2026-09-09.

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 44 seconds.

What the second review verified

  • Re-ran all four checks and needs_action for all 51 devices myself and got the same result on every row. Edge cases also match: LT-013, whose warranty ends on the audit date (2026-11-30), is ok; LT-025, last seen exactly 30 days before, is ok; Anders Mbeki (status active, end_date 2026-11-14) is a leaver; Clementine Vasquez (end_date 2026-12-12) is not.
  • The summary counts match the audit file: devices 51, needs_action 24, leaver 6, not_on_staff 2, unassigned 2, missing 6, expired 13, no_date 1, duplicate_serial 2, no_serial 1.
  • Recomputed laptop counts per person. Only four people who haven't left have a count other than 1: E108 and E116 have 2 each (LT-010 and LT-041; LT-018 and LT-019), and E125 and E127 have 0. These match staff_laptops.csv.
  • The day counts in the reasons are right (LT-005: 33, LT-006: 45, LT-026: 93, TB-03: 77). LT-028 'Iggy Thornbury' is correctly flagged not_on_staff and named as most likely Ignatius Thornbury (E125). The CRV-1Q5Z39H/crv-1q5z39h duplicate between LT-010 and LT-040 was caught regardless of capital letters.

What this run does not show

  • The device list and staff list are sample data written for this run, so a real device list will be messier than the planted problems here.
  • Where an owner name matched nobody, the guess at who was meant is read only by the second review.

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 9 of 9. 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 the device list against staff

function: it
for: the IT manager who answers for every laptop, phone and tablet
goal: Every device has a known owner, a known whereabouts and a known warranty state, and every gap is listed with the reason.

## 1. Read the lists and the rules
Read input/devices.csv, input/staff.csv and input/audit_rules.md. The rules give the audit date and
how long without a check-in makes a device missing.
A person has left when end_date in the staff list is filled in and is on or before the audit date,
whatever the status column says.
Match assigned_to to a person by email, ignoring capital letters and spaces around it. When
assigned_to holds a name and not an email, match it to the full name on the staff list, ignoring
capital letters. Do not guess that a short name or a different spelling is the same person.

## 2. Run four checks on every device
- owner_check: when assigned_to is blank, `in_stock` if status is spare or retired, otherwise
  `unassigned`. When it is filled in: `not_on_staff` if it matches nobody, `leaver` if the person
  has left, `ok` otherwise.
- seen_check: `not_applicable` when status is spare or retired. Otherwise `missing` when last_seen
  is blank or the audit date minus last_seen is more days than the rules allow, and `ok` if not.
- warranty_check: `not_applicable` when status is retired. Otherwise `no_date` when warranty_end is
  blank, `expired` when warranty_end is before the audit date, and `ok` if not.
- record_check: `no_serial` when serial is blank, `duplicate_serial` when another row has the same
  serial ignoring capital letters, and `ok` if not.
needs_action is `yes` when owner_check is unassigned, not_on_staff or leaver, or seen_check is
missing, or warranty_check is expired or no_date, or record_check is not ok. Otherwise `no`.
Then count laptops per person: laptops that are not retired and whose owner_check is ok. Every
person who has not left should have exactly one.

## 3. Write the audit
Write output/device_audit.csv with columns
asset_tag,owner_check,seen_check,warranty_check,record_check,needs_action,reason. One row per
device. reason is one plain sentence naming the facts behind any check that is not ok. Where a
name matched nobody, say which staff member it most likely means.
Write output/staff_laptops.csv with columns employee_id,name,laptops,finding. One row for each
person who has not left and whose laptop count is not 1. finding is `no_laptop` or `more_than_one`.
Write output/summary.md for the IT manager. Start with these lines in the form `name: count`:
devices, needs_action, leaver, not_on_staff, unassigned, missing, expired, no_date,
duplicate_serial, no_serial. devices is the number of rows, needs_action is the number marked
yes, and each other count is the number of devices with that result in device_audit.csv. Then list every device held by a leaver with the person's name and
end date, every missing device with its last check-in, and the people without exactly one laptop.

## Done looks like
- Every device appears once in device_audit.csv with all four checks filled in.
- Every person without exactly one laptop is in staff_laptops.csv.
- The counts in summary.md equal the counts in device_audit.csv.
input/audit_rules.md · 13 lines, 848 bytes
# Larkmoor Outfitters device audit rules

Audit date: 2026-11-30

1. Every device that is in use is assigned to one person on the staff list. The device list should
   carry that person's work email. Older rows carry a name instead.
2. When someone leaves, their devices come back to IT on their last day.
3. A device that is in use and has not checked in to the management tool for more than 30 days is
   treated as missing until someone finds it. A device that has never checked in is also missing.
4. Spare devices sit switched off in the store room. Retired devices are wiped and waiting for
   collection. Check-in does not apply to either. Warranty does not apply to retired devices.
5. A device is out of warranty from the day after its warranty end date.
6. Everyone on the staff list has exactly one laptop. Retired laptops do not count.
input/devices.csv · 52 lines, 5 KB
asset_tag,type,model,serial,assigned_to,status,purchase_date,warranty_end,last_seen
LT-001,laptop,Corvid 16 Pro,CRV-8K2M41Q,marisol.kettering@larkmoor.example,in_use,2024-03-11,2027-03-11,2026-11-30
LT-002,laptop,Corvid 14,CRV-3D7T90B,thaddeus.nwosu@larkmoor.example,in_use,2022-09-05,2025-09-05,2026-11-29
LT-003,laptop,Corvid 14,CRV-5H1W62N,adaeze.lindqvist@larkmoor.example,in_use,2024-01-22,2027-01-22,2026-11-30
LT-004,laptop,Corvid 14,CRV-9P4X17C,tomasz.verhoeven@larkmoor.example,in_use,2024-06-17,2027-06-17,2026-11-28
LT-005,laptop,Corvid 14,CRV-2B6R83F,priya.castellanos@larkmoor.example,in_use,2024-01-22,2027-01-22,2026-10-28
LT-006,laptop,Corvid 14,CRV-7J0Y55L,hollis.brandvold@larkmoor.example,in_use,2023-09-04,2026-09-04,2026-10-16
LT-007,laptop,Larch Air 13,LAR-41TQ7782,noor.fairweather@larkmoor.example,in_use,2025-02-10,2028-02-10,2026-11-30
LT-008,laptop,Larch Air 13,LAR-41TQ7790,desmond.achterberg@larkmoor.example,in_use,2025-02-10,,2026-11-27
LT-009,laptop,Corvid 16 Pro,CRV-6N8S24D,ingrid.solheim-park@larkmoor.example,in_use,2024-07-29,2027-07-29,2026-11-30
LT-010,laptop,Corvid 16 Pro,CRV-1Q5Z39H,kwabena.rothwell@larkmoor.example,in_use,2024-10-07,2027-10-07,2026-11-30
LT-011,laptop,Corvid 16 Pro,CRV-4G2V76K,yuki.marchetti@larkmoor.example,in_use,2024-05-20,2027-05-20,2026-11-29
LT-012,laptop,Corvid 16 Pro,CRV-0M9U18R,callum.oyelaran@larkmoor.example,in_use,2023-02-06,2026-02-06,2026-11-22
LT-013,laptop,Corvid 14,CRV-8E3A60T,farah.dunmore@larkmoor.example,in_use,2023-12-01,2026-11-30,2026-11-26
LT-014,laptop,Corvid 16 Pro,CRV-5C7K92W,leopold.nakashima@larkmoor.example,in_use,2025-05-12,2028-05-12,2026-11-30
LT-015,laptop,Corvid 16 Pro,CRV-3X1F47Y,sunniva.abernathy@larkmoor.example,in_use,2025-01-13,2028-01-13,2026-11-30
LT-016,laptop,Corvid 14,CRV-9L6B05G,rashad.pemberton@larkmoor.example,in_use,2024-04-02,2027-04-02,2026-11-30
LT-017,laptop,Corvid 14,CRV-2T8D31J,beatrix.holloway@larkmoor.example,in_use,2022-08-08,2025-08-08,2026-11-28
LT-018,laptop,Corvid 14,CRV-7R4H68M,mateo.grunewald@larkmoor.example,in_use,2024-03-29,2027-03-29,2026-11-12
LT-019,laptop,Larch Air 13,LAR-39KD2051,mateo.grunewald@larkmoor.example,in_use,2023-06-19,2026-06-19,2026-11-30
LT-020,laptop,Corvid 14,CRV-6W0P23S,oluwaseun.whitlock@larkmoor.example,in_use,2024-09-12,2027-09-12,2026-11-30
LT-021,laptop,Corvid 14,CRV-1Y5N84V,clementine.vasquez@larkmoor.example,in_use,2024-01-23,2027-01-23,2026-11-27
LT-022,laptop,Larch Air 13,LAR-44MB6120,anders.mbeki@larkmoor.example,in_use,2025-06-17,2028-06-17,2026-11-13
LT-023,laptop,Corvid 14,CRV-4S9E50X,Tabitha Rosenthal,in_use,2023-10-23,2026-10-23,2026-11-30
LT-024,laptop,Corvid 14,CRV-0A2J71Z,emeka.lindgren@larkmoor.example,in_use,2024-07-05,2027-07-05,2026-11-30
LT-025,laptop,Corvid 14,CRV-8U6G13B,saoirse.bellamy@larkmoor.example,in_use,2024-04-17,2027-04-17,2026-10-31
LT-026,laptop,Corvid 14,CRV-5F3L96C,dmitri.hargreaves@larkmoor.example,in_use,2023-11-08,2026-11-08,2026-08-29
LT-027,laptop,Corvid 14,CRV-3K7Q28D,wren.castillo@larkmoor.example,in_use,2024-02-12,2027-02-12,2026-11-30
LT-028,laptop,Corvid 14,CRV-9V1C45F,Iggy Thornbury,in_use,2023-06-01,2026-06-01,2026-11-25
LT-029,laptop,Larch Air 13,LAR-40RS8834,lucinda.abara@larkmoor.example,in_use,2025-03-14,2028-03-14,2026-11-28
LT-030,laptop,Larch Air 13,LAR-42HV1009,philippa.zielinski@larkmoor.example,in_use,2025-10-02,2028-10-02,2026-11-30
LT-031,laptop,Larch Air 13,LAR-43EX5567,Bartholomew.Singh@larkmoor.example,in_use,2025-02-24,2028-02-24,2026-11-30
LT-032,laptop,Corvid 14,CRV-2Z8T60G,odalys.fenwick@larkmoor.example,in_use,2024-08-16,2027-08-16,2026-11-24
LT-033,laptop,Corvid 14,CRV-7H4M37H,kieran.mahlangu@larkmoor.example,in_use,2024-11-07,2027-11-07,2026-11-20
LT-034,laptop,Larch Air 13,LAR-45JC3391,rosalind.tavares@larkmoor.example,in_use,2025-05-12,2028-05-12,2026-11-30
LT-035,laptop,Larch Air 13,LAR-45JC3402,,spare,2025-05-12,2028-05-12,2026-06-03
LT-036,laptop,Corvid 14,CRV-6B0W82J,,spare,2022-08-08,2025-08-08,2026-03-19
LT-037,laptop,Corvid 13,CRV-1D5R19K,,retired,2020-04-20,2023-04-20,2025-12-11
LT-038,laptop,Corvid 14,CRV-4N9Y54L,,in_use,2024-06-17,2027-06-17,2026-11-29
LT-039,laptop,Corvid 16 Pro,CRV-0P2S76M,j.merrow@brightquill.example,in_use,2024-10-07,2027-10-07,2026-10-28
LT-040,laptop,Corvid 16 Pro,crv-1q5z39h,,spare,2024-10-07,2027-10-07,
LT-041,laptop,Corvid 16 Pro,,kwabena.rothwell@larkmoor.example,in_use,2025-09-01,2028-09-01,2026-11-30
PH-01,phone,Pebble 9,PBL-770214,beatrix.holloway@larkmoor.example,in_use,2025-01-06,2027-01-06,2026-11-30
PH-02,phone,Pebble 9,PBL-770215,mateo.grunewald@larkmoor.example,in_use,2025-01-06,2027-01-06,2026-11-30
PH-03,phone,Pebble 9,PBL-770216,oluwaseun.whitlock@larkmoor.example,in_use,2025-01-06,2027-01-06,
PH-04,phone,Pebble 9,PBL-770217,kieran.mahlangu@larkmoor.example,in_use,2025-01-06,2027-01-06,2026-11-21
PH-05,phone,Pebble 8,PBL-512093,marisol.kettering@larkmoor.example,in_use,2023-05-15,2025-05-15,2026-11-30
PH-06,phone,Pebble 9,PBL-770218,,spare,2025-01-06,2027-01-06,2025-01-09
TB-01,tablet,Slate T10,SLT-20318, ignatius.thornbury@larkmoor.example,in_use,2024-09-09,2026-09-09,2026-11-30
TB-02,tablet,Slate T10,SLT-20319,gideon.farrow@larkmoor.example,in_use,2024-09-09,2026-09-09,2026-11-30
TB-03,tablet,Slate T10,SLT-20320,,in_use,2024-09-09,2026-09-09,2026-09-14
TB-04,tablet,Slate T8,SLT-11872,,retired,2021-03-01,2023-03-01,2025-02-20
input/staff.csv · 35 lines, 3 KB
employee_id,name,email,department,job_title,status,start_date,end_date
E101,Adaeze Lindqvist,adaeze.lindqvist@larkmoor.example,Finance,Finance Director,active,2019-03-04,
E102,Tomasz Verhoeven,tomasz.verhoeven@larkmoor.example,Finance,Accountant,active,2021-06-14,
E103,Priya Castellanos,priya.castellanos@larkmoor.example,Finance,Accounts Payable Clerk,active,2022-01-10,
E104,Hollis Brandvold,hollis.brandvold@larkmoor.example,Finance,Payroll Specialist,left,2020-09-01,2026-10-16
E105,Noor Fairweather,noor.fairweather@larkmoor.example,People,People Lead,active,2018-11-19,
E106,Desmond Achterberg,desmond.achterberg@larkmoor.example,People,Recruiter,active,2023-02-06,
E107,Ingrid Solheim-Park,ingrid.solheim-park@larkmoor.example,Engineering,Engineering Manager,active,2019-07-22,
E108,Kwabena Rothwell,kwabena.rothwell@larkmoor.example,Engineering,Software Developer,active,2021-10-04,
E109,Yuki Marchetti,yuki.marchetti@larkmoor.example,Engineering,Software Developer,active,2022-05-16,
E110,Callum Oyelaran,callum.oyelaran@larkmoor.example,Engineering,Software Developer,left,2020-02-03,2026-09-30
E111,Farah Dunmore,farah.dunmore@larkmoor.example,Engineering,Quality Tester,active,2023-08-28,
E112,Leopold Nakashima,leopold.nakashima@larkmoor.example,IT,IT Manager,active,2017-05-08,
E113,Sunniva Abernathy,sunniva.abernathy@larkmoor.example,IT,Systems Administrator,active,2020-01-13,
E114,Rashad Pemberton,rashad.pemberton@larkmoor.example,IT,Help Desk Technician,active,2024-04-02,
E115,Beatrix Holloway,beatrix.holloway@larkmoor.example,Sales,Sales Director,active,2018-08-06,
E116,Mateo Grunewald,mateo.grunewald@larkmoor.example,Sales,Account Executive,active,2021-03-29,
E117,Oluwaseun Whitlock,oluwaseun.whitlock@larkmoor.example,Sales,Account Executive,active,2022-09-12,
E118,Clementine Vasquez,clementine.vasquez@larkmoor.example,Sales,Account Executive,active,2023-01-23,2026-12-12
E119,Anders Mbeki,anders.mbeki@larkmoor.example,Sales,Sales Development Rep,active,2024-06-17,2026-11-14
E120,Tabitha Rosenthal,tabitha.rosenthal@larkmoor.example,Customer Support,Support Lead,active,2019-10-21,
E121,Emeka Lindgren,emeka.lindgren@larkmoor.example,Customer Support,Support Agent,active,2022-07-05,
E122,Saoirse Bellamy,saoirse.bellamy@larkmoor.example,Customer Support,Support Agent,active,2023-04-17,
E123,Dmitri Hargreaves,dmitri.hargreaves@larkmoor.example,Customer Support,Support Agent,left,2021-11-08,2026-08-29
E124,Wren Castillo,wren.castillo@larkmoor.example,Operations,Operations Manager,active,2018-02-12,
E125,Ignatius Thornbury,ignatius.thornbury@larkmoor.example,Operations,Warehouse Supervisor,active,2020-06-01,
E126,Lucinda Abara,lucinda.abara@larkmoor.example,Operations,Purchasing Coordinator,active,2022-03-14,
E127,Gideon Farrow,gideon.farrow@larkmoor.example,Operations,Warehouse Associate,active,2024-09-09,
E128,Marisol Kettering,marisol.kettering@larkmoor.example,Leadership,Chief Executive,active,2016-01-04,
E129,Thaddeus Nwosu,thaddeus.nwosu@larkmoor.example,Leadership,Chief Operating Officer,active,2017-09-18,
E130,Philippa Zielinski,philippa.zielinski@larkmoor.example,Finance,Financial Analyst,active,2023-10-02,
E131,Bartholomew Singh,bartholomew.singh@larkmoor.example,Engineering,Data Analyst,active,2025-02-24,
E132,Odalys Fenwick,odalys.fenwick@larkmoor.example,People,Office Coordinator,active,2021-08-16,
E133,Kieran Mahlangu,kieran.mahlangu@larkmoor.example,Sales,Account Executive,left,2022-11-07,2026-11-21
E134,Rosalind Tavares,rosalind.tavares@larkmoor.example,Customer Support,Support Agent,active,2025-05-12,
output/device_audit.csv · written by the agent, 52 lines
asset_tag,owner_check,seen_check,warranty_check,record_check,needs_action,reason
LT-001,ok,ok,ok,ok,no,
LT-002,ok,ok,expired,ok,yes,Warranty ended 2025-09-05.
LT-003,ok,ok,ok,ok,no,
LT-004,ok,ok,ok,ok,no,
LT-005,ok,missing,ok,ok,yes,"Last check-in was 2026-10-28, 33 days before the audit (limit 30)."
LT-006,leaver,missing,expired,ok,yes,"Held by Hollis Brandvold, who left on 2026-10-16. Last check-in was 2026-10-16, 45 days before the audit (limit 30). Warranty ended 2026-09-04."
LT-007,ok,ok,ok,ok,no,
LT-008,ok,ok,no_date,ok,yes,There is no warranty end date.
LT-009,ok,ok,ok,ok,no,
LT-010,ok,ok,ok,duplicate_serial,yes,Serial CRV-1Q5Z39H is also on LT-040.
LT-011,ok,ok,ok,ok,no,
LT-012,leaver,ok,expired,ok,yes,"Held by Callum Oyelaran, who left on 2026-09-30. Warranty ended 2026-02-06."
LT-013,ok,ok,ok,ok,no,
LT-014,ok,ok,ok,ok,no,
LT-015,ok,ok,ok,ok,no,
LT-016,ok,ok,ok,ok,no,
LT-017,ok,ok,expired,ok,yes,Warranty ended 2025-08-08.
LT-018,ok,ok,ok,ok,no,
LT-019,ok,ok,expired,ok,yes,Warranty ended 2026-06-19.
LT-020,ok,ok,ok,ok,no,
LT-021,ok,ok,ok,ok,no,
LT-022,leaver,ok,ok,ok,yes,"Held by Anders Mbeki, who left on 2026-11-14."
LT-023,ok,ok,expired,ok,yes,Warranty ended 2026-10-23.
LT-024,ok,ok,ok,ok,no,
LT-025,ok,ok,ok,ok,no,
LT-026,leaver,missing,expired,ok,yes,"Held by Dmitri Hargreaves, who left on 2026-08-29. Last check-in was 2026-08-29, 93 days before the audit (limit 30). Warranty ended 2026-11-08."
LT-027,ok,ok,ok,ok,no,
LT-028,not_on_staff,ok,expired,ok,yes,"Assigned to 'Iggy Thornbury', who is not on the staff list; most likely Ignatius Thornbury (E125). Warranty ended 2026-06-01."
LT-029,ok,ok,ok,ok,no,
LT-030,ok,ok,ok,ok,no,
LT-031,ok,ok,ok,ok,no,
LT-032,ok,ok,ok,ok,no,
LT-033,leaver,ok,ok,ok,yes,"Held by Kieran Mahlangu, who left on 2026-11-21."
LT-034,ok,ok,ok,ok,no,
LT-035,in_stock,not_applicable,ok,ok,no,
LT-036,in_stock,not_applicable,expired,ok,yes,Warranty ended 2025-08-08.
LT-037,in_stock,not_applicable,not_applicable,ok,no,
LT-038,unassigned,ok,ok,ok,yes,It is in use but has nobody assigned.
LT-039,not_on_staff,missing,ok,ok,yes,"Assigned to 'j.merrow@brightquill.example', who is not on the staff list; no staff member is a likely match. Last check-in was 2026-10-28, 33 days before the audit (limit 30)."
LT-040,in_stock,not_applicable,ok,duplicate_serial,yes,Serial crv-1q5z39h is also on LT-010.
LT-041,ok,ok,ok,no_serial,yes,The serial number is blank.
PH-01,ok,ok,ok,ok,no,
PH-02,ok,ok,ok,ok,no,
PH-03,ok,missing,ok,ok,yes,It has never checked in.
PH-04,leaver,ok,ok,ok,yes,"Held by Kieran Mahlangu, who left on 2026-11-21."
PH-05,ok,ok,expired,ok,yes,Warranty ended 2025-05-15.
PH-06,in_stock,not_applicable,ok,ok,no,
TB-01,ok,ok,expired,ok,yes,Warranty ended 2026-09-09.
TB-02,ok,ok,expired,ok,yes,Warranty ended 2026-09-09.
TB-03,unassigned,missing,expired,ok,yes,"It is in use but has nobody assigned. Last check-in was 2026-09-14, 77 days before the audit (limit 30). Warranty ended 2026-09-09."
TB-04,in_stock,not_applicable,not_applicable,ok,no,
output/staff_laptops.csv · written by the agent, 5 lines
employee_id,name,laptops,finding
E108,Kwabena Rothwell,2,more_than_one
E116,Mateo Grunewald,2,more_than_one
E125,Ignatius Thornbury,0,no_laptop
E127,Gideon Farrow,0,no_laptop
output/summary.md · written by the agent, 40 lines
devices: 51
needs_action: 24
leaver: 6
not_on_staff: 2
unassigned: 2
missing: 6
expired: 13
no_date: 1
duplicate_serial: 2
no_serial: 1

Audit date: 2026-11-30. Missing means no check-in for more than 30 days, or never.

## Devices held by leavers
- LT-006 (laptop): Hollis Brandvold, left 2026-10-16
- LT-012 (laptop): Callum Oyelaran, left 2026-09-30
- LT-022 (laptop): Anders Mbeki, left 2026-11-14
- LT-026 (laptop): Dmitri Hargreaves, left 2026-08-29
- LT-033 (laptop): Kieran Mahlangu, left 2026-11-21
- PH-04 (phone): Kieran Mahlangu, left 2026-11-21

## Missing devices
- LT-005: last check-in 2026-10-28
- LT-006: last check-in 2026-10-16
- LT-026: last check-in 2026-08-29
- LT-039: last check-in 2026-10-28
- PH-03: last check-in never
- TB-03: last check-in 2026-09-14

## People without exactly one laptop
- E108 Kwabena Rothwell: 2 laptops (more_than_one)
- E116 Mateo Grunewald: 2 laptops (more_than_one)
- E125 Ignatius Thornbury: 0 laptops (no_laptop)
- E127 Gideon Farrow: 0 laptops (no_laptop)

## Devices with no matching owner
- LT-028: Assigned to 'Iggy Thornbury', who is not on the staff list; most likely Ignatius Thornbury (E125). Warranty ended 2026-06-01.
- LT-038: It is in use but has nobody assigned.
- LT-039: Assigned to 'j.merrow@brightquill.example', who is not on the staff list; no staff member is a likely match. Last check-in was 2026-10-28, 33 days before the audit (limit 30).
- TB-03: It is in use but has nobody assigned. Last check-in was 2026-09-14, 77 days before the audit (limit 30). Warranty ended 2026-09-09.
check.py · the check, written before the run
"""Recomputes the four checks for every device and the laptop count per person, then compares."""
import csv, re, sys
from datetime import date
from pathlib import Path

COUNTS = ["devices", "needs_action", "leaver", "not_on_staff", "unassigned", "missing", "expired", "no_date", "duplicate_serial", "no_serial"]

NUM = re.compile(r"(?<![\w.-])\d(?:[\d,]*\d)?(?:\.\d+)?(?![\w-])")
DAY = re.compile(r"\d{4}-\d{2}-\d{2}")

def rows(p):
    with p.open(newline="") as fh:
        return list(csv.DictReader(fh))

def low(s):
    return (s or "").strip().lower()

def expected(root):
    inp = root / "input"
    rules = (inp / "audit_rules.md").read_text()
    day = date.fromisoformat(re.search(r"Audit date:\s*(\d{4}-\d{2}-\d{2})", rules).group(1))
    max_days = int(re.search(r"more than (\d+) days", rules).group(1))
    staff = rows(inp / "staff.csv")
    by_email = {low(p["email"]): p for p in staff}
    by_name = {low(p["name"]): p for p in staff}
    left = lambda p: bool(p["end_date"].strip()) and date.fromisoformat(p["end_date"].strip()) <= day
    devices = rows(inp / "devices.csv")
    serials = {}
    for d in devices:
        if d["serial"].strip(): serials[low(d["serial"])] = serials.get(low(d["serial"]), 0) + 1
    want, laptops = {}, {}
    for d in devices:
        status, who = low(d["status"]), d["assigned_to"].strip()
        person = None
        if not who:
            owner = "in_stock" if status in ("spare", "retired") else "unassigned"
        else:
            person = by_email.get(low(who)) if "@" in who else by_name.get(low(who))
            owner = "not_on_staff" if not person else "leaver" if left(person) else "ok"
        if status in ("spare", "retired"): seen = "not_applicable"
        else:
            last = d["last_seen"].strip()
            seen = "missing" if not last or (day - date.fromisoformat(last)).days > max_days else "ok"
        if status == "retired": warranty = "not_applicable"
        else:
            w = d["warranty_end"].strip()
            warranty = "no_date" if not w else "expired" if date.fromisoformat(w) < day else "ok"
        record = "no_serial" if not d["serial"].strip() else "duplicate_serial" if serials[low(d["serial"])] > 1 else "ok"
        action = "yes" if owner in ("unassigned", "not_on_staff", "leaver") or seen == "missing" or warranty in ("expired", "no_date") or record != "ok" else "no"
        last_seen = d["last_seen"].strip()
        twins = {x["asset_tag"].strip() for x in devices if d["serial"].strip() and low(x["serial"]) == low(d["serial"])}
        want[d["asset_tag"].strip()] = {"owner_check": owner, "seen_check": seen, "warranty_check": warranty, "record_check": record, "needs_action": action,
                                        "person": person["name"] if person else "", "end": person["end_date"].strip() if person else "", "last": last_seen,
                                        "dates": {day.isoformat(), last_seen, d["warranty_end"].strip(), d["purchase_date"].strip(), person["end_date"].strip() if person else ""},
                                        "days": {max_days} | ({(day - date.fromisoformat(last_seen)).days} if last_seen else set()),
                                        "serial": low(d["serial"]), "warranty": d["warranty_end"].strip(), "twins": twins, "max_days": max_days, "day": day.isoformat()}
        if low(d["type"]) == "laptop" and status != "retired" and owner == "ok":
            laptops[person["employee_id"]] = laptops.get(person["employee_id"], 0) + 1
    gaps = {p["employee_id"]: ("no_laptop" if laptops.get(p["employee_id"], 0) == 0 else "more_than_one", laptops.get(p["employee_id"], 0), p["name"])
            for p in staff if not left(p) and laptops.get(p["employee_id"], 0) != 1}
    return want, gaps

def main():
    root = Path(sys.argv[1]); ok = True
    def say(passed, text):
        nonlocal ok
        ok = ok and passed; print(("PASS " if passed else "FAIL ") + text)
    want, gaps = expected(root)
    path = root / "output/device_audit.csv"
    if not path.exists():
        say(False, "output/device_audit.csv was not written"); sys.exit(1)
    got_rows = rows(path)
    got = {(r.get("asset_tag") or "").strip(): {k: low(v) for k, v in r.items() if k} for r in got_rows}
    n = len(want)
    say(len(got_rows) == n and set(got) == set(want), f"{len(set(got) & set(want))} of {n} devices appear once in device_audit.csv")
    for col, label in [("owner_check", "owner checks equal the result recomputed from the staff list"),
                       ("seen_check", "check-in results equal the result recomputed from the last seen dates")]:
        c = sum(1 for k, w in want.items() if got.get(k, {}).get(col) == w[col])
        say(c == n, f"{c} of {n} {label}")
    c = sum(1 for k, w in want.items() if all(got.get(k, {}).get(col) == w[col] for col in ("warranty_check", "record_check", "needs_action")))
    say(c == n, f"{c} of {n} devices have the right warranty result, serial result and needs action flag")
    spath = root / "output/staff_laptops.csv"
    sgot = {(r.get("employee_id") or "").strip(): r for r in rows(spath)} if spath.exists() else {}
    g = sum(1 for k, (finding, count, name) in gaps.items() if low(sgot.get(k, {}).get("finding")) == finding and low(sgot.get(k, {}).get("laptops")) == str(count)
            and (sgot.get(k, {}).get("name") or "").strip() == name)
    extra = len(set(sgot) - set(gaps))
    say(g == len(gaps) and extra == 0, f"{g} of {len(gaps)} people without exactly one laptop are in staff_laptops.csv with the right name and count and {extra} people are listed by mistake")
    staff_names = {p["name"] for p in rows(root / "input/staff.csv")}
    serials = {w["serial"] for w in want.values() if w["serial"]}
    def tags_in(text):
        return [t for t in want if re.search(r"(?<![\w-])" + re.escape(t) + r"(?!\d)", text)]
    def honest(text, k, known_owner=True):
        w = want[k]
        if any(d not in w["dates"] for d in DAY.findall(text)): return False
        bare = DAY.sub(" ", text)
        for t in tags_in(bare): bare = bare.replace(t, " ")
        if any(len(m.group(0)) >= 2 and float(m.group(0).replace(",", "")) not in w["days"] for m in NUM.finditer(bare)): return False
        if any(int(x) not in w["days"] for x in re.findall(r"(?<![\w.-])(\d+) days?\b", bare)): return False
        if any(t != k and t not in w["twins"] for t in tags_in(text)): return False
        if any(s in text.lower() and s != w["serial"] for s in serials): return False
        if known_owner and any(nm in text and nm != w["person"] for nm in staff_names): return False
        return True
    def reason_ok(k):
        w, text = want[k], (got_text.get(k) or "").strip()
        calm = w["needs_action"] == "no"
        if calm: return not (DAY.search(text) or tags_in(text) or re.search(r"serial|warranty|check-in|checked in", text, re.I) or any(nm in text for nm in staff_names))
        if len(text.split()) < 3 or not honest(text, k, known_owner=w["owner_check"] != "not_on_staff"): return False
        if w["warranty_check"] == "expired" and w["warranty"] not in text: return False
        if w["owner_check"] == "leaver" and w["person"] not in text: return False
        if w["record_check"] == "duplicate_serial" and not (set(tags_in(text)) & (w["twins"] - {k})): return False
        if w["seen_check"] == "missing" and w["last"] and w["last"] not in text: return False
        return True
    got_text = {(r.get("asset_tag") or "").strip(): (r.get("reason") or "") for r in got_rows}
    r_ok = sum(1 for k in want if reason_ok(k))
    acting = sum(1 for w in want.values() if w["needs_action"] == "yes")
    say(r_ok == n, f"{r_ok} of {n} reasons fit the device: {acting} name the facts behind what is wrong, with no date, day count, serial or person from another device, and {n - acting} name no problem")
    summary = (root / "output/summary.md").read_text() if (root / "output/summary.md").exists() else ""
    tally = {"devices": n, "needs_action": sum(1 for w in want.values() if w["needs_action"] == "yes")}
    for name in COUNTS[2:]:
        tally[name] = sum(1 for w in want.values() if name in (w["owner_check"], w["seen_check"], w["warranty_check"], w["record_check"]))
    s_ok = 0
    for name in COUNTS:
        m = re.search(r"(?<![a-z_])" + name + r"[`*\s]*:[`*\s]*(\d+)", summary)
        if m and int(m.group(1)) == tally[name]: s_ok += 1
    held = [(k, w["person"]) for k, w in want.items() if w["owner_check"] == "leaver"]
    lines = summary.splitlines()
    named = sum(1 for k, person in held if any(k in tags_in(ln) and person in ln and want[k]["end"] in ln for ln in lines))
    say(s_ok == len(COUNTS) and named == len(held), f"{s_ok} of {len(COUNTS)} counts in summary.md equal the recomputed counts and {named} of {len(held)} devices held by leavers are named with the person and end date")
    lost = [k for k, w in want.items() if w["seen_check"] == "missing"]
    l_ok = sum(1 for k in lost if any(k in tags_in(ln) and (want[k]["last"] in ln if want[k]["last"] else re.search(r"never|no check-in|not checked in|blank|none", ln, re.I)) for ln in lines))
    def person_line(name, count):
        for ln in lines:
            said = re.findall(r"(?<![\w.-])(\d+) laptops?\b", ln)
            if name in ln and (said == [str(count)] or (not said and re.search(r"(?<![\w.-])" + str(count) + r"(?![\w.-])", ln.replace(name, " ")))): return True
        return False
    p_ok = sum(1 for _, (finding, count, name) in gaps.items() if person_line(name, count))
    say(l_ok == len(lost) and p_ok == len(gaps), f"summary.md lists {l_ok} of {len(lost)} missing devices with their last check-in and {p_ok} of {len(gaps)} people without exactly one laptop with their laptop count")
    seen_n = bad = 0
    any_w = next(iter(want.values()))
    totals = {float(v) for v in tally.values()} | {float(any_w["max_days"]), float(len(gaps)), float(len(lost)), float(len(held))}
    ends = {p["name"]: p["end_date"].strip() for p in rows(root / "input/staff.csv")}
    for ln in lines:
        tags = tags_in(ln); names = [nm for nm in staff_names if nm in ln]
        days = {any_w["day"]} if not (tags or names) else set()
        nums = set(totals)
        for t in tags: days |= want[t]["dates"]; nums |= {float(x) for x in want[t]["days"]}
        for nm in names: days.add(ends[nm])
        bare = DAY.sub(" ", ln)
        for t in tags: bare = bare.replace(t, " ")
        for d in DAY.findall(ln):
            seen_n += 1; bad += d not in days
        for m in NUM.finditer(bare):
            if len(m.group(0)) >= 2:
                seen_n += 1; bad += float(m.group(0).replace(",", "")) not in nums
    say(seen_n > 0 and bad == 0, f"{seen_n - bad} of {seen_n} dates and numbers in summary.md match the device list, the staff list or the recomputed counts")
    sys.exit(0 if ok else 1)

if __name__ == "__main__":
    main()

audit_rules.md: sample data written by Atris. Fingerprint 5cdb09a1ff6c.

devices.csv: sample data written by Atris. Fingerprint c93a61cc9621.

staff.csv: sample data written by Atris. Fingerprint d06060ba1b29.

device_audit.csv: written by the agent. Fingerprint 6a914ff4d926.

staff_laptops.csv: written by the agent. Fingerprint eec47c9ca6b0.

summary.md: written by the agent. Fingerprint a67e5adecca6.


More it and security work, and every other desk job

For agentsGitHub
What is AtrisBlogApp StorePricingPrivacyTerms