Atris

Sort a day's inbox and draft replies.
Done by an agent. Checked twice.

A day's inbox sorted into four piles under written rules, with a draft ready for each message that needs a reply today.

Have Atris do this for you›

1

Real files in

  • contacts.csv
    The executive's contact list: 17 people by email address with their role. 18 lines, 1 KB.
  • inbox.csv
    One day's inbox export for a chief executive: 42 messages, with a repeated message, a blank subject, bulk mail and a known name writing from an unknown address. 43 lines, 10 KB.
  • owner.md
    A short note saying whose inbox this is and what the two lists are for. 7 lines, 388 bytes.
  • owners.csv
    Which team member handles which subject, by keyword. 16 lines, 630 bytes.

Sample data written by Atris. Not a real company.

2

Three steps

  1. 1.Read the inbox and the lists
  2. 2.Put every message in one pile
  3. 3.Draft the replies for today

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

3

Checked twice

  • ✓Passed: 42 of 42 messages appear once in sorted.csv
  • ✓Passed: 42 of 42 piles and 42 of 42 rule names equal the ones worked out again from the written rules (12 reply_today, 7 delegate, 17 read_later, 6 ignore)
  • ✓Passed: 7 of 7 delegated messages name the owner from the owners list and 0 other messages carry an owner
  • ✓Passed: 1 of 1 messages from a known name at an unknown address are marked check_sender and 0 others are
  • ✓Passed: 12 of 12 reply today messages have a draft and 0 drafts were written for other messages
  • ✓Passed: 12 of 12 drafts greet the sender by the name in the contact list, run 30 to 150 words and use no figure that is not in the message. The page heading uses only the inbox date

Second review by Claude Opus 5.5: pass.

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

What it wrote. Lines 1 to 13 of sorted.csv, copied from the file.
message_id,bucket,rule,owner,note
M-001,delegate,keyword,Ruben Castellanos,
M-002,ignore,bulk,,
M-003,reply_today,vip,,
M-004,reply_today,vip,,
M-005,ignore,duplicate,,
M-006,read_later,default,,
M-007,delegate,keyword,Samira Obuya,
M-008,reply_today,vip,,
M-009,reply_today,team_today,,
M-010,read_later,default,,
M-011,read_later,default,,check_sender
M-012,reply_today,vip,,

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

  • I re-sorted all 42 messages using the rules in order and every row in sorted.csv matches. For example, M-025 from investor Per Lindqvist correctly goes to ignore/bulk because the body contains "unsubscribe", and M-029 from Dana.Whitlock@quarrystonecap.example matches the contact list regardless of capital letters, so it goes to reply_today/vip with no check_sender note.
  • The sender-owner skips are handled correctly. M-006 (Ruben, "invoice"), M-013 (Clio, "podcast"), M-017 (Dev, "outage"), M-022 (Ingrid, "contract") and M-041 (Hana, "renewal") all go to read_later/default. M-007 goes to Samira because "candidate" is a whole word in the body, and M-015 goes to Hana because of "renewal".
  • check_sender appears only on M-011, where the display name "Dana Whitlock" comes with dwhitlock.personal@swiftpost.example. M-012 has the display name "Katerina Novak", which is not an exact contact name, so it rightly has no note. Its draft greets "Katarina", spelled as in contacts.csv.
  • There are 12 drafts, and they match the 12 reply_today rows exactly (M-003, 004, 008, 009, 012, 016, 020, 024, 029, 033, 038, 042). Every figure used appears in the message it answers, such as 1,900 in M-033, 4:30 in M-024, 15 and 10 percent in M-020, and November 30 / December 5 in M-042. Each draft is roughly 40–90 words, uses square-bracket gaps for the executive's decisions, and is signed "Mireille".

What this run does not show

  • The piles follow six written rules applied by the letter. The check cannot tell whether a message a person would call urgent was sorted well.
  • The inbox was written for this run so that each rule has clear cases. A real inbox has more messages that fit no rule.
  • The drafts are tested for greeting, length and stray figures. Whether a draft answers the message and promises nothing 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 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
# Sort a day's inbox and draft replies

function: leadership
for: the assistant or chief of staff who runs an executive's inbox
goal: Every message from the day sits in one of four piles under the same written rules, and each one that needs a reply today has a draft waiting.

## 1. Read the inbox and the lists
Read input/owner.md, input/inbox.csv, input/contacts.csv and input/owners.csv. Match a sender to
contacts.csv by email address only, ignoring capital letters. A sender whose address is not in
contacts.csv is unknown, whatever the display name says.

## 2. Put every message in one pile
Work through the messages in the order received. Give each one the first rule that applies. Apply the
rules by the letter and in this order, not by feel:
1. `ignore`, rule `duplicate`: an earlier message has the same from_email, subject and body.
2. `ignore`, rule `bulk`: the body contains the word "unsubscribe" in any capitals, or from_email starts
   with "noreply@" or "no-reply@".
3. `reply_today`, rule `vip`: the sender's role is board, investor or key_customer and addressed is `to`.
4. `reply_today`, rule `team_today`: the sender's role is team, addressed is `to`, and the body
   contains both a question mark and the word "today".
5. `delegate`, rule `keyword`: the subject or body contains a keyword from owners.csv as a whole word
   or phrase, ignoring capitals. Use the first keyword in the order of owners.csv that appears. The
   owner is that row's owner. If the sender is that owner, skip this rule.
6. `read_later`, rule `default`: everything else.
Separately, when from_name is exactly a name in contacts.csv but from_email is not that contact's
address, put `check_sender` in the note column. The pile still follows the rules above.
Write output/sorted.csv with columns message_id,bucket,rule,owner,note. One row for each message.
owner is filled only for delegate.

## 3. Draft the replies for today
Write output/drafts.md with one section for each reply_today message and for no other message. Head
each section with the message id, like `## M-003`. Each draft:
- greets the sender by first name, spelled as in contacts.csv;
- is 30 to 150 words and answers what the message asks;
- uses no figure, date or time that is not in the message it answers;
- makes no promise and no decision on the executive's behalf. Where only the executive can answer,
  leave the gap in square brackets, like [to confirm: which date works];
- is signed with the executive's first name from owner.md.

## Done looks like
- Every message appears once in sorted.csv with one of the four piles.
- Every reply_today message has a draft and no other message has one.
- No draft contains a figure, a promise or a decision that is not in the message.
input/contacts.csv · 18 lines, 1 KB
email,name,role,note
dana.whitlock@quarrystonecap.example,Dana Whitlock,board,Board chair
gideon@parkadvisory.example,Gideon Park,board,Independent director
p.lindqvist@northpierventures.example,Per Lindqvist,investor,"Lead investor, seed round"
amara.oyelaran@quarrystonecap.example,Amara Oyelaran,investor,Works with Dana Whitlock
helen.brandvold@tessmoorhealth.example,Helen Brandvold,key_customer,Largest customer
katarina.novak@ridgewellfoods.example,Katarina Novak,key_customer,
owen.tiller@cobaltharbor.example,Owen Tiller,key_customer,Up for renewal in January
ruben.castellanos@sablewood.example,Ruben Castellanos,team,Finance lead
ingrid.halloran@sablewood.example,Ingrid Halloran,team,General counsel
samira.obuya@sablewood.example,Samira Obuya,team,Head of people
dev.ramaswamy@sablewood.example,Dev Ramaswamy,team,Head of engineering
clio.bergstrom@sablewood.example,Clio Bergstrom,team,Marketing lead
hana.whitfield@sablewood.example,Hana Whitfield,team,Head of customer success
josefina.adler@sablewood.example,Josefina Adler,team,Chief of staff
theo.marchetti@sablewood.example,Theo Marchetti,team,Head of sales
accounts@brightloomcloud.example,Brightloom Cloud Billing,vendor,Hosting provider
lars@penhallowprint.example,Lars Penhallow,vendor,Printer for event materials
input/inbox.csv · 43 lines, 10 KB
message_id,received,from_name,from_email,addressed,subject,body
M-001,2026-12-01T06:12,Brightloom Cloud Billing,accounts@brightloomcloud.example,to,Your November invoice is ready,"Hello, your invoice for November is ready. Amount due: 8,412.00. Payment is due by December 15. View it in your account."
M-002,2026-12-01T06:40,The Ledgerline Weekly,noreply@ledgerlineweekly.example,to,Five things finance teams got wrong this year,"Our weekly round up is here. Read online. To stop getting these emails, unsubscribe here."
M-003,2026-12-01T07:05,Dana Whitlock,dana.whitlock@quarrystonecap.example,to,Board deck for the 10th,"Mireille, can you send me the draft board deck by Thursday? I want to read it before the pre-call on Monday. Also, are we still planning to cover the pricing change?"
M-004,2026-12-01T07:18,Helen Brandvold,helen.brandvold@tessmoorhealth.example,to,Dashboard numbers do not match our export,"Mireille, the weekly dashboard showed 4,180 visits for the Northgate clinic and our own export says 3,960. My team presents this to our board on Friday. Can someone tell me which is right before then?"
M-005,2026-12-01T07:21,Helen Brandvold,helen.brandvold@tessmoorhealth.example,to,Dashboard numbers do not match our export,"Mireille, the weekly dashboard showed 4,180 visits for the Northgate clinic and our own export says 3,960. My team presents this to our board on Friday. Can someone tell me which is right before then?"
M-006,2026-12-01T07:44,Ruben Castellanos,ruben.castellanos@sablewood.example,to,November close,"The November invoice run is done and the books will close on the 4th. Nothing needed from you. Cash is 40,000 ahead of the forecast I sent last month."
M-007,2026-12-01T08:02,Marco Deluca,marco@peakform-recruiting.example,to,Three senior candidates for your data team,"Hi Mireille, I have three people who would be a strong fit for your open roles. Each candidate is available for an interview next week. Worth a quick call?"
M-008,2026-12-01T08:15,Per Lindqvist,p.lindqvist@northpierventures.example,to,Quick question on runway,"Mireille, one of my partners asked how many months of runway you have after the two new hires. Could you send me the current figure and what it assumes? No rush past this week."
M-009,2026-12-01T08:20,Samira Obuya,samira.obuya@sablewood.example,to,Offer for the analytics lead,"We agreed 148,000 base with the candidate and I need your sign off to send the letter. Can you approve today? She has another offer that runs out tomorrow at noon."
M-010,2026-12-01T08:31,Josefina Adler,josefina.adler@sablewood.example,cc,Re: offsite venue,Copying Mireille so she has it. The venue has us held for January 21 and 22. I will confirm today unless anyone objects?
M-011,2026-12-01T08:47,Dana Whitlock,dwhitlock.personal@swiftpost.example,to,Urgent favor,"Mireille, I am in meetings all day and cannot talk. I need you to buy 6 gift cards of 500 each for a client and send me the codes by email. I will pay you back tonight. Keep this between us."
M-012,2026-12-01T09:03,Katerina Novak,katarina.novak@ridgewellfoods.example,to,,"Hi Mireille, we would like to add our two bakeries in the north to the account from January. Can you tell me what that does to our price? Our current plan covers 12 sites."
M-013,2026-12-01T09:10,Clio Bergstrom,clio.bergstrom@sablewood.example,to,Podcast invite from Field Notes,Field Notes wants you on their podcast in January. I think it is worth doing. I will handle the booking and send you prep notes.
M-014,2026-12-01T09:26,Trevanion Software,hello@trevanion-software.example,to,Cut your reporting time in half,"Hi Mireille, teams like yours use Trevanion to build reports faster. Can I show you a 15 minute demo this week? If this is not for you, unsubscribe below."
M-015,2026-12-01T09:41,Owen Tiller,owen.tiller@cobaltharbor.example,cc,Re: Open support ticket 2291,"Hana, copying Mireille for visibility. The export has failed three nights in a row and my team is doing it by hand. Our renewal is in January and this is not helping."
M-016,2026-12-01T09:58,Gideon Park,gideon@parkadvisory.example,to,Audit committee date,"Mireille, the auditors have offered December 16 or December 18 for the planning call. Which works for you? I am free both mornings."
M-017,2026-12-01T10:07,Dev Ramaswamy,dev.ramaswamy@sablewood.example,to,"Last night's outage, summary",Summary for you. The export job was down from 01:10 to 03:25. The cause was a full disk on the reporting server. It is fixed and we added an alert. Full write up comes Thursday.
M-018,2026-12-01T10:15,Lars Penhallow,lars@penhallowprint.example,to,Proofs for the event banners,"Hi, the proofs for the 4 banners are attached. We need a yes by Friday to print in time for the 12th."
M-019,2026-12-01T10:22,Amara Oyelaran,amara.oyelaran@quarrystonecap.example,cc,Re: Intro to Fenwick Labs,"Thanks Theo, copying Mireille. Happy to make the intro to their head of data once you send me two lines on what you are after."
M-020,2026-12-01T10:40,Theo Marchetti,theo.marchetti@sablewood.example,to,Discount for Cobalt Harbor,Owen is asking for 15 percent off to renew for two years. I can hold at 10. Do you want me to go to 15 if he pushes? I am seeing him today at 3.
M-021,2026-12-01T10:52,Northpier Ventures,updates@northpierventures.example,to,"Northpier portfolio news, December","What our companies shipped this quarter, three new investments and our annual event date. You get this because you are a portfolio founder. Unsubscribe at any time."
M-022,2026-12-01T11:05,Ingrid Halloran,ingrid.halloran@sablewood.example,to,"Tessmoor contract, clause 9",Tessmoor's lawyers want to cap our liability at 12 months of fees. Our standard is 24. I think 12 is acceptable for a customer this size. Do you agree?
M-023,2026-12-01T11:16,Wilhelmina Strand,w.strand@harborlight-events.example,to,Speaking slot at Data Leaders Forum,"Dear Mireille, we would love to have you on a panel at the Data Leaders Forum on March 4. The speaking slot is 40 minutes. Could you let us know by December 12?"
M-024,2026-12-01T11:30,Hana Whitfield,hana.whitfield@sablewood.example,to,Cobalt Harbor is unhappy,"Owen's export has failed three nights running. Dev says last night's fix should hold. I would like you to call Owen today. Would 4:30 work, after Theo has seen him?"
M-025,2026-12-01T11:48,Per Lindqvist,p.lindqvist@northpierventures.example,to,Northpier portfolio dinner,"Mireille, we are hosting founders for dinner on January 14 in the city. Details to follow. You can unsubscribe from event notes if you would rather not get them."
M-026,2026-12-01T12:04,Josefina Adler,josefina.adler@sablewood.example,to,Agenda for Thursday leadership meeting,"Draft agenda attached. Items so far: hiring plan, the Tessmoor data question and Q1 goals. Send me anything you want added."
M-027,2026-12-01T12:19,Rafael Quintero,rafael.q@lumen-ridge.example,to,Partnership idea,"Hi Mireille, I run a small firm that builds dashboards for clinics. I think our customers overlap. Would you be open to a call in the new year?"
M-028,2026-12-01T12:33,Brightloom Cloud Billing,accounts@brightloomcloud.example,to,Payment failed for card ending 4471,We could not take payment for your November invoice. Please update your card within 5 days to avoid a pause in service.
M-029,2026-12-01T12:50,Dana Whitlock,Dana.Whitlock@quarrystonecap.example,to,One more thing for the board,"Mireille, please add 10 minutes on the Cobalt Harbor situation to the agenda. I heard about it from Owen directly. Can you tell me where it stands?"
M-030,2026-12-01T13:08,Samira Obuya,samira.obuya@sablewood.example,to,Holiday rota,The rota for the last two weeks of December is in the shared folder. Engineering has cover on every day. No action needed.
M-031,2026-12-01T13:22,Ottoline Pryce,ottoline@thecurrentdesk.example,to,Comment for a story on health data,"Hello, I write for The Current Desk. I am working on a piece about how clinics use data and would like a comment from you for the press this week. My deadline is Thursday at 5."
M-032,2026-12-01T13:40,Katarina Novak,katarina.novak@ridgewellfoods.example,cc,Re: Training session for new site managers,Thanks Hana. The 9th at 10 works for us. Copying Mireille as she asked to be kept posted.
M-033,2026-12-01T14:02,Dev Ramaswamy,dev.ramaswamy@sablewood.example,to,Need a decision on the reporting server,"We can move reporting to a bigger server for 1,900 a month or keep patching. I want to order it today so it is in place before the weekend. Yes or no?"
M-034,2026-12-01T14:15,Sablewood Calendar,no-reply@sablewood.example,to,Reminder: leadership meeting Thursday 10:00,This is an automatic reminder for the leadership meeting on Thursday at 10:00 in the main room.
M-035,2026-12-01T14:31,Gideon Park,gideon@parkadvisory.example,cc,Re: Audit fee proposal,"Ruben, the fee of 46,000 looks in line with last year. Copying Mireille. I am fine to approve unless she sees a problem."
M-036,2026-12-01T14:48,Elias Thornquist,elias@thornquist-legal.example,to,NDA for our call next week,"Hi Mireille, ahead of our call about the data sharing project, please find our NDA attached. Could you sign and return it before Tuesday?"
M-037,2026-12-01T15:05,Theo Marchetti,theo.marchetti@sablewood.example,cc,Re: Fenwick Labs intro,"Amara, two lines as promised. Copying Mireille. We are after their head of data to talk about a pilot in Q1."
M-038,2026-12-01T15:20,Owen Tiller,owen.tiller@cobaltharbor.example,to,Can we talk,"Mireille, I would rather hear from you than from three different people. Are you free for a call tomorrow morning? Any time before 11 works."
M-039,2026-12-01T15:42,Clio Bergstrom,clio.bergstrom@sablewood.example,to,Case study sign off,"The Ridgewell case study is ready. Can you read it and tell me if the quote from you is right? No hurry, it goes out next week."
M-040,2026-12-01T16:10,Jun Aldabra,jun.aldabra@sablewood.example,to,Thank you,"Hi Mireille, I wanted to say thanks for the time last week. The advice on the roadmap talk helped a lot."
M-041,2026-12-01T16:35,Hana Whitfield,hana.whitfield@sablewood.example,to,Renewal forecast for January,Seven accounts come up in January. Five look safe. Cobalt Harbor and one small account are in doubt. Full list is in the tracker.
M-042,2026-12-01T17:12,Amara Oyelaran,amara.oyelaran@quarrystonecap.example,to,Numbers for our year end review,"Mireille, for our year end review could you send revenue, customer count and headcount as of November 30? We need them by December 5."
input/owner.md · 7 lines, 388 bytes
# Whose inbox this is

Inbox of Mireille Anand, chief executive of Sablewood Analytics. Export of every message received on
Tuesday, December 1, 2026. Mireille's assistant sorts the inbox once at the end of the day.

- contacts.csv: the people Mireille knows, by email address, with their role.
- owners.csv: who on the team handles which subject. A message on that subject goes to them.
input/owners.csv · 16 lines, 630 bytes
keyword,owner,area
invoice,Ruben Castellanos,Money in and out
invoices,Ruben Castellanos,Money in and out
payment,Ruben Castellanos,Money in and out
contract,Ingrid Halloran,Legal
NDA,Ingrid Halloran,Legal
candidate,Samira Obuya,Hiring and people
interview,Samira Obuya,Hiring and people
outage,Dev Ramaswamy,Product and systems
bug,Dev Ramaswamy,Product and systems
incident,Dev Ramaswamy,Product and systems
press,Clio Bergstrom,Marketing and events
podcast,Clio Bergstrom,Marketing and events
speaking,Clio Bergstrom,Marketing and events
renewal,Hana Whitfield,Customers
support ticket,Hana Whitfield,Customers
output/drafts.md · written by the agent, 135 lines
# Draft replies for Tuesday, December 1, 2026

Gaps in square brackets are for Mireille to fill. Nothing here is sent.

## M-003

Dana,

Thank you for the note about the board deck. I have your request to see the draft by Thursday, ahead of the pre-call on Monday. [to confirm: whether the draft can go to Dana by Thursday]

On your question about the pricing change: [to confirm: whether the pricing change is still on the agenda for the board deck].

Best,
Mireille

## M-004

Helen,

Thank you for flagging this, and I am sorry the dashboard and your export do not agree for the Northgate clinic. I understand your team presents to your board on Friday and needs to know which number is right before then.

[to confirm: which figure is correct, and who on our team will confirm it to Helen before Friday]

Best,
Mireille

## M-008

Per,

Thank you for asking on behalf of your partner. You would like the current runway in months after the two new hires, and what that figure assumes.

[to confirm: the runway figure in months, with the assumptions behind it, and whether Mireille will send it this week]

Best,
Mireille

## M-009

Samira,

Thank you for setting this out. I understand you agreed the base salary with the candidate, and that she has another offer that runs out tomorrow at noon, so you need an answer today.

[to confirm: whether Mireille approves the offer as agreed, so the letter can be sent]

Best,
Mireille

## M-012

Katarina,

Thank you for your note. We would be glad to talk about adding your two bakeries in the north to the account from January, on top of the plan that covers 12 sites today.

On what that does to your price: [to confirm: the price effect of adding the two sites, and who will send the figures to Katarina].

Best,
Mireille

## M-016

Gideon,

Thank you for getting the auditors' options to me. You mentioned December 16 or December 18 for the planning call, and that you are free both mornings.

[to confirm: which date works, December 16 or December 18]

Best,
Mireille

## M-020

Theo,

Thanks for the update on Cobalt Harbor. I understand Owen is asking for 15 percent off to renew for two years, that you can hold at 10, and that you see him today at 3.

[to confirm: whether Theo may go to 15 percent if Owen pushes, or must hold at 10]

Best,
Mireille

## M-024

Hana,

Thanks for the heads up on Cobalt Harbor, and for passing on Dev's view that last night's fix should hold. I understand you would like me to call Owen today, after Theo has seen him.

[to confirm: whether a call with Owen at 4:30 works]

Best,
Mireille

## M-029

Dana,

Thank you for the note. I have your request to add time on the Cobalt Harbor situation to the board agenda. [to confirm: whether the 10 minutes can be added to the agenda]

On where things stand: [to confirm: a short status on Cobalt Harbor to share with Dana].

Best,
Mireille

## M-033

Dev,

Thanks for laying out the choice. I understand the options are moving reporting to a bigger server for 1,900 a month or continuing to patch, and that you want to order today so it is in place before the weekend.

[to confirm: yes or no on the bigger reporting server]

Best,
Mireille

## M-038

Owen,

Thank you for writing to me directly. I hear you would rather talk with me than with three different people, and I am sorry for the frustration.

On your question about a call tomorrow morning, any time before 11: [to confirm: whether Mireille is free tomorrow morning and at what time].

Best,
Mireille

## M-042

Amara,

Thank you for the note about your year end review. You asked for revenue, customer count and headcount as of November 30, needed by December 5.

[to confirm: whether Mireille will send all three figures by December 5, and who will pull them]

Best,
Mireille
output/sorted.csv · written by the agent, 43 lines
message_id,bucket,rule,owner,note
M-001,delegate,keyword,Ruben Castellanos,
M-002,ignore,bulk,,
M-003,reply_today,vip,,
M-004,reply_today,vip,,
M-005,ignore,duplicate,,
M-006,read_later,default,,
M-007,delegate,keyword,Samira Obuya,
M-008,reply_today,vip,,
M-009,reply_today,team_today,,
M-010,read_later,default,,
M-011,read_later,default,,check_sender
M-012,reply_today,vip,,
M-013,read_later,default,,
M-014,ignore,bulk,,
M-015,delegate,keyword,Hana Whitfield,
M-016,reply_today,vip,,
M-017,read_later,default,,
M-018,read_later,default,,
M-019,read_later,default,,
M-020,reply_today,team_today,,
M-021,ignore,bulk,,
M-022,read_later,default,,
M-023,delegate,keyword,Clio Bergstrom,
M-024,reply_today,team_today,,
M-025,ignore,bulk,,
M-026,read_later,default,,
M-027,read_later,default,,
M-028,delegate,keyword,Ruben Castellanos,
M-029,reply_today,vip,,
M-030,read_later,default,,
M-031,delegate,keyword,Clio Bergstrom,
M-032,read_later,default,,
M-033,reply_today,team_today,,
M-034,ignore,bulk,,
M-035,read_later,default,,
M-036,delegate,keyword,Ingrid Halloran,
M-037,read_later,default,,
M-038,reply_today,vip,,
M-039,read_later,default,,
M-040,read_later,default,,
M-041,read_later,default,,
M-042,reply_today,vip,,
check.py · the check, written before the run
"""Sorts the inbox again under the written rules and compares it with the agent's piles and drafts."""
import csv, re, sys
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 nums(text): return {n.replace(",", "") for n in re.findall(r"\d[\d,]*\d|\d", text)}

msgs = sorted(csv.DictReader((root/"input/inbox.csv").open()), key=lambda r: (r["received"], r["message_id"]))
contacts = {r["email"].lower(): r for r in csv.DictReader((root/"input/contacts.csv").open())}
by_name = {r["name"].lower(): e for e, r in contacts.items()}
owners = list(csv.DictReader((root/"input/owners.csv").open()))
want, seen = {}, set()
for m in msgs:
    email, c = m["from_email"].lower(), contacts.get(m["from_email"].lower())
    key, text = (email, m["subject"], m["body"]), m["subject"] + " " + m["body"]
    hit = next((o for o in owners if re.search(rf"\b{re.escape(o['keyword'])}\b", text, re.I)), None)
    flag = m["from_name"].lower() in by_name and by_name[m["from_name"].lower()] != email
    if key in seen: bucket, owner, rule = "ignore", "", "duplicate"
    elif "unsubscribe" in m["body"].lower() or email.startswith(("noreply@", "no-reply@")): bucket, owner, rule = "ignore", "", "bulk"
    elif c and c["role"] in ("board", "investor", "key_customer") and m["addressed"] == "to": bucket, owner, rule = "reply_today", "", "vip"
    elif c and c["role"] == "team" and m["addressed"] == "to" and "?" in m["body"] and re.search(r"\btoday\b", m["body"], re.I): bucket, owner, rule = "reply_today", "", "team_today"
    elif hit and not (c and c["name"] == hit["owner"]): bucket, owner, rule = "delegate", hit["owner"], "keyword"
    else: bucket, owner, rule = "read_later", "", "default"
    seen.add(key); want[m["message_id"]] = (bucket, owner, flag, m, c, rule)

path = root/"output/sorted.csv"
if not path.exists():
    say(False, "output/sorted.csv was not written"); sys.exit(1)
rows = list(csv.DictReader(path.open())); got = {r.get("message_id", ""): r for r in rows}
once = sum(1 for k in want if sum(1 for r in rows if r.get("message_id") == k) == 1)
say(once == len(want) and len(rows) == len(want), f"{once} of {len(want)} messages appear once in sorted.csv")
right = sum(1 for k, w in want.items() if (got.get(k, {}).get("bucket") or "").strip() == w[0])
piles = ", ".join(f"{sum(1 for w in want.values() if w[0] == b)} {b}" for b in ("reply_today", "delegate", "read_later", "ignore"))
ruled = sum(1 for k, w in want.items() if (got.get(k, {}).get("rule") or "").strip() == w[5])
say(right == len(want) and ruled == len(want), f"{right} of {len(want)} piles and {ruled} of {len(want)} rule names equal the ones worked out again from the written rules ({piles})")
dele = [k for k, w in want.items() if w[0] == "delegate"]
own = sum(1 for k in dele if (got.get(k, {}).get("owner") or "").strip() == want[k][1])
loose = sum(1 for k in want if k not in dele and (got.get(k, {}).get("owner") or "").strip())
say(own == len(dele) and loose == 0, f"{own} of {len(dele)} delegated messages name the owner from the owners list and {loose} other messages carry an owner")
flags = [k for k, w in want.items() if w[2]]
marked = [k for k in want if "check_sender" in (got.get(k, {}).get("note") or "")]
say(set(flags) == set(marked), f"{len(set(flags) & set(marked))} of {len(flags)} messages from a known name at an unknown address are marked check_sender and {len(set(marked) - set(flags))} others are")
drafts_text = (root/"output/drafts.md").read_text() if (root/"output/drafts.md").exists() else ""
parts = re.split(r"(?m)^#+\s*(M-\d+).*$", drafts_text); drafts = {parts[i]: parts[i+1] for i in range(1, len(parts) - 1, 2)}
today = [k for k, w in want.items() if w[0] == "reply_today"]
say(set(drafts) == set(today), f"{len(set(drafts) & set(today))} of {len(today)} reply today messages have a draft and {len(set(drafts) - set(today))} drafts were written for other messages")
good = 0
for k in today:
    d, m, c = drafts.get(k, ""), want[k][3], want[k][4]
    first = (c["name"] if c else m["from_name"]).split()[0]
    if re.search(rf"\b{re.escape(first)}\b", d) and 30 <= len(d.split()) <= 150 and nums(d) <= nums(m["subject"] + " " + m["body"]): good += 1
head_ok = nums(parts[0]) <= nums(" ".join(m["received"] for m in msgs) + (root/"input/owner.md").read_text())
say(good == len(today) and today and head_ok, f"{good} of {len(today)} drafts greet the sender by the name in the contact list, run 30 to 150 words and use no figure that is not in the message. The page heading uses {'only' if head_ok else 'more than'} the inbox date")
sys.exit(0 if ok else 1)

contacts.csv: sample data written by Atris. Fingerprint 9f0a8681eaa5.

inbox.csv: sample data written by Atris. Fingerprint 8a371706309f.

owner.md: sample data written by Atris. Fingerprint 0363f2bf1523.

owners.csv: sample data written by Atris. Fingerprint cd0cbc2be08e.

drafts.md: written by the agent. Fingerprint 8240d3abe742.

sorted.csv: written by the agent. Fingerprint f59a925af965.


More the founder's office work, and every other desk job

For agentsGitHub
What is AtrisBlogApp StorePricingPrivacyTerms