Atris

Log and answer personal data requests.
Done by an agent. Checked twice.

Every inbox message logged with type, deadline and repeat link, plus a draft reply in approved wording for a person to send.

Have Atris do this for you›

1

Real files in

  • as_of.txt
    The date to treat as today. 1 lines, 11 bytes.
  • procedure.md
    A company's written procedure for personal data requests: types, deadlines, repeats, which reply to use and the approved sentences. 59 lines, 4 KB.
  • requests.csv
    26 messages from a privacy inbox over six weeks, with repeats, requests sent for someone else, messages that are not data requests and one with no received date. 27 lines, 4 KB.

Sample data written by Atris. Not a real company.

2

Three steps

  1. 1.Read the procedure and the inbox
  2. 2.Log every message
  3. 3.Write the log and the draft replies

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

3

Checked twice

  • ✓Passed: 26 of 26 messages are logged exactly once, and 26 of 26 notes are one sentence
  • ✓Passed: 26 of 26 types equal the type the procedure gives for the message (22 data requests, 4 not a request)
  • ✓Passed: 26 of 26 due dates, days left and timings equal the values worked out from the received date (5 overdue)
  • ✓Passed: 26 of 26 reply kinds equal the first one that applies in the procedure, and 2 repeats point at the right earlier request
  • ✓Passed: 26 of 26 drafts greet the right person, carry the reference and hold the approved sentence for their kind and no other
  • ✓Passed: 18 of 18 drafts that owe a deadline state the right date, and the apology appears in 5 of 5 overdue drafts and nowhere else
  • ✓Passed: replies.md opens by saying these are drafts for a person to approve and not legal advice

Second review by Claude Opus 5.5: pass.

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

What it wrote. Lines 1 to 12 of request_log.csv, copied from the file.
request_id,type,due_date,days_left,timing,reply,duplicate_of,note
REQ-3101,access,2026-11-23,-8,overdue,confirm,,"Access request whose 30-day date fell on a Saturday so it moved to Monday, and it is now overdue."
REQ-3102,delete,2026-11-25,-6,overdue,ask_id,,"Delete request with no ID check done, so the reply asks for photo ID."
REQ-3103,access,2026-11-30,-1,overdue,confirm,,"Access request that also asks who the data was shared with, which the reply does not answer."
REQ-3104,correct,2026-12-02,1,due_soon,confirm,,"Correct request with ID passed, so the reply confirms."
REQ-3105,not_a_request,,,,to_support,,"Billing complaint and refund request, not a personal data request, so it goes to member support."
REQ-3106,access,2026-12-07,6,due_soon,confirm,,"Access request whose 30-day date fell on a Saturday so it moved to Monday, and it is the earlier of two from the same address."
REQ-3107,access,2026-12-07,6,due_soon,duplicate,REQ-3106,"Same email address as REQ-3106 (capital letters ignored, first name spelled Kathryn) five days later, so it is a duplicate and keeps that due date."
REQ-3108,stop_marketing,2026-11-18,-13,overdue,marketing_stopped,,"Stop marketing request whose 10-day date has passed, and a second request from the same address followed."
REQ-3109,access,2026-12-09,8,on_time,ask_authority,,"Access request sent on behalf of the writer's father, so the reply asks for a signed letter."
REQ-3110,delete,2026-12-14,13,on_time,confirm,,"Asks for access and then erasure, so it is logged as delete with access named here."
REQ-3111,delete,2026-12-14,13,on_time,no_account,,Delete request with no account found under this email address.

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 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 2 of 2 on 1 December 2026. The agent took 57 seconds. Run 1 passed both checks and the job was run again later. Each run starts clean. Between runs the written flow was made clearer, or a check was corrected or made stricter. Nobody edits the output.

What the second review verified

  • I recalculated every due date with a script from the received date and the procedure's 10 and 30 day rules plus the weekend rule. All 26 rows match except where a match isn't expected. REQ-3101 lands on Saturday 2026-11-21 and moves to Monday 2026-11-23 (-8 days, overdue). REQ-3106 lands on Saturday 2026-12-05 and moves to 2026-12-07 (6 days, due_soon).
  • Repeats are handled correctly. REQ-3107 (K.Moss, same address once capitals are ignored, 5 days later) and REQ-3116 (12 days after REQ-3108) are marked as duplicates and keep the earlier due dates, 2026-12-07 and 2026-11-18. REQ-3120 comes 34 days after REQ-3101 and REQ-3114 is a different type from REQ-3102, so both are correctly treated as new requests.
  • The reply order is followed. REQ-3119 gets no_account before marketing_stopped. REQ-3109 and REQ-3122 get ask_authority before ask_id. Mixed requests REQ-3110 (access and erase) and REQ-3124 (unsubscribe and delete) are logged as delete, with the other type named in the note. REQ-3118 has no received date, so it gets no_date, no due date and no deadline sentence.
  • The drafts use the approved sentences word for word. 'We are sorry that our answer is late.' appears only in the overdue replies: 3101, 3102, 3103, 3108 and 3116. The deadline sentence is left out of the to_support, no_account and marketing_stopped replies. The header line is exact, there are 26 sections in request_id order, and each note is one sentence.

What this run does not show

  • Request types are tested by keyword from the written procedure, so a request phrased in an unexpected way could be sorted wrongly without the check seeing it.
  • The check tests only the approved sentences, names and dates in each draft reply while the rest of the wording is read by the second review alone.
  • Run 1 passed with one minor note on long notes, so the check was made stricter and run 2 is a fresh run under it.

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 4 of 4.

Open every file

flow.md · the three steps the agent followed
# Log and answer personal data requests

function: legal
for: the privacy or legal lead who must answer every personal data request on time
goal: Every message in the privacy inbox is logged with its type and deadline, and a reply is drafted under the written procedure for a person to approve.

## 1. Read the procedure and the inbox
Read input/procedure.md first. It is the company's own written procedure and it decides everything:
the types, the deadlines, what counts as a repeat, which reply to use and the approved sentences.
Then read input/requests.csv, one row per message, and take today's date from input/as_of.txt. Read
each message in full. Decide on what it actually asks for, not on a single word.

## 2. Log every message
Work through the procedure in its own order for each message: type, deadline, timing, repeats, reply.
Where the procedure gives an order, use the first that applies. Where a field is missing, do what
the procedure says and do not guess. Work out dates with a script, not by eye.

## 3. Write the log and the draft replies
Write output/request_log.csv with columns request_id,type,due_date,days_left,timing,reply,duplicate_of,note.
One row per message, in request_id order. due_date as year-month-day. days_left is the due date minus
today. Leave due_date, days_left and timing empty when the procedure gives no due date, except that
a missing received date gets the timing the procedure names. duplicate_of holds the id of the request
it repeats, otherwise it is empty. note is exactly one plain sentence on the thing a reviewer most
needs to know. Never write two sentences in a note. Join the facts with a comma or drop the lesser one.
Write output/replies.md. The first line must read exactly:
Drafts for a person to approve before sending. Not legal advice.
Then one part per message, in request_id order, under a heading of two hash marks and the request id.
Draft each reply exactly as the procedure's drafting step says, with its approved sentences word for
word.

## Done looks like
- Every message has one log row and one draft reply.
- Every due date can be worked out again from the received date and the procedure.
- Every draft contains the approved sentence for its kind and nothing the procedure does not allow.
input/as_of.txt · 1 lines, 11 bytes
2026-12-01
input/procedure.md · 59 lines, 4 KB
# Quenby Fitness Clubs: personal data request procedure

Owner: Head of Legal. Version 3, in force from 2026-07-01. This is the company's own procedure. Follow it step by step for every message in the privacy inbox.

## 1. Decide what the message asks for

Give each message one type.

- `delete`: the person asks us to delete or erase their personal data.
- `access`: the person asks for a copy of their personal data, or asks what data we hold about them.
- `correct`: the person asks us to correct, update or fix a detail we hold about them.
- `stop_marketing`: the person asks us to stop sending marketing, or to take them off a mailing list.
- `not_a_request`: the message asks for none of these. Billing questions, cancelling a membership, opening hours and job applications are not personal data requests.

If one message asks for more than one of these, log the type that comes first in this order: delete, access, correct, stop_marketing. Name the other type in the note.

## 2. Work out the deadline

- `stop_marketing` is due 10 calendar days after the day it was received.
- `delete`, `access` and `correct` are due 30 calendar days after the day it was received.
- If the due date is a Saturday or Sunday, it moves to the Monday after.
- `not_a_request` has no due date.
- If the received date is missing, do not guess it. Leave the due date empty and set timing to `no_date`.

Timing compares the due date with today: `overdue` when the due date has passed, `due_soon` when it is today or within the next 7 days, `on_time` when it is more than 7 days away.

## 3. Spot repeats

A request is a `duplicate` when the same email address (ignoring capital letters) sent a request of the same type no more than 30 days earlier. Point it at the earliest such request. A duplicate keeps the due date of the request it repeats. A request that arrives more than 30 days after the earlier one is a new request with its own deadline.

## 4. Choose the reply

Use the first reply in this list that applies.

1. `to_support`: the type is not_a_request.
2. `duplicate`: the request is a duplicate under step 3.
3. `no_account`: account_match is no.
4. `marketing_stopped`: the type is stop_marketing. No identity check is needed for this.
5. `ask_authority`: the message is sent on behalf of another person.
6. `ask_id`: id_check is anything other than passed.
7. `confirm`: everything else.

## 5. Draft the reply

Every reply opens with "Dear" and the first name of the person who wrote, then a line "Reference:" with the request id. Then it must contain the approved sentence for its kind, word for word:

- to_support: This is not a personal data request, so we have passed it to our member support team.
- duplicate: We are already handling this under reference followed by the id of the earlier request and a full stop.
- no_account: We could not find an account under the email address you wrote from.
- marketing_stopped: We have taken you off our marketing lists.
- ask_authority: Before we can act, please send us a signed letter from the person you are writing for.
- ask_id: Before we can act, please send us a copy of a photo ID so that we can confirm who you are.
- confirm: We have confirmed who you are and are working on your request.

Replies of kind duplicate, ask_authority, ask_id and confirm also state the deadline in this sentence: Our deadline to answer is followed by the due date written year-month-day and a full stop. Leave that sentence out when there is no due date.

If timing is overdue, the reply also contains this sentence: We are sorry that our answer is late. No other reply may contain it.

Keep replies short. Do not give legal advice, do not promise anything this procedure does not promise, and do not say what data we hold. Every reply is a draft. A person in Legal reads it before it is sent.
input/requests.csv · 27 lines, 4 KB
request_id,received_date,channel,name,email,message,account_match,id_check
REQ-3101,2026-10-22,email,Priya Raman,priya.raman@mailhaven.example,Please send me a copy of all the personal data you hold about me.,yes,passed
REQ-3102,2026-10-26,web form,Tomasz Wilk,t.wilk@postbox.example,"I closed my membership in June. Delete my data please, all of it.",yes,not done
REQ-3103,2026-10-30,email,Edda Lindqvist,edda.lindqvist@mailhaven.example,"What information do you have on file about me, and who have you shared it with?",yes,passed
REQ-3104,2026-11-02,email,Marcus Oyelaran,m.oyelaran@postbox.example,You have my date of birth wrong on my membership record. It should be 14 March 1988. Please correct it.,yes,passed
REQ-3105,2026-11-03,phone note,Hannah Voss,hannah.voss@inboxly.example,Caller wants to know why she was charged twice in October and wants a refund.,yes,not done
REQ-3106,2026-11-05,email,Katherine Moss,k.moss@inboxly.example,"I would like a copy of my data, including my gym visit history.",yes,passed
REQ-3107,2026-11-10,email,Kathryn Moss,K.Moss@inboxly.example,Following up. I still want a copy of my data and visit history.,yes,passed
REQ-3108,2026-11-08,web form,Ibrahim Saleh,ibrahim.saleh@postbox.example,Please take me off your mailing list. I get three emails a week.,yes,not done
REQ-3109,2026-11-09,email,Dorothy Achterberg,d.achterberg@mailhaven.example,"I am writing on behalf of my father, Willem Achterberg, who is a member at your Eastgate club. Please send me a copy of the data you hold about him.",yes,not done
REQ-3110,2026-11-12,email,Luca Ferraro,luca.ferraro@inboxly.example,Send me everything you hold about me and then erase all my data.,yes,passed
REQ-3111,2026-11-13,email,Selma Haddad,selma.h@postbox.example,Please delete my personal information.,no,not done
REQ-3112,2026-11-16,web form,Owen Castellano,owen.castellano@mailhaven.example,I want to cancel my membership from next month.,yes,passed
REQ-3113,2026-11-17,email,Grace Nwosu,grace.nwosu@inboxly.example,"My address has changed. Please update my record: 9 Alder Court, flat 2.",yes,failed
REQ-3114,2026-11-18,email,Tomasz Wilk,t.wilk@postbox.example,Separate from my other request: please send me a copy of whatever you hold about me.,yes,not done
REQ-3115,2026-11-19,phone note,Beatrix Holm,beatrix.holm@postbox.example,Caller asked what time the Northside club opens on public holidays.,yes,not done
REQ-3116,2026-11-20,email,Ibrahim Saleh,ibrahim.saleh@postbox.example,I asked you to stop the marketing emails and they are still coming. Stop them.,yes,not done
REQ-3117,2026-11-23,email,Yusuf Demir,yusuf.demir@mailhaven.example,Please confirm what personal data you hold about me and give me a copy of it.,yes,passed
REQ-3118,,post,Agnes Thorburn,agnes.thorburn@inboxly.example,"Letter asks for a copy of all records held about her, including CCTV images. Envelope was not date stamped.",yes,not done
REQ-3119,2026-11-24,email,Rafael Quintero,rafa.quintero@postbox.example,I don't want any more promotional texts or emails.,no,not done
REQ-3120,2026-11-25,email,Priya Raman,priya.raman@mailhaven.example,It has been over a month. Where is the copy of my data?,yes,passed
REQ-3121,2026-11-26,web form,Nadia Petrenko,nadia.petrenko@inboxly.example,Your app shows my surname as Petrenco. Please fix the spelling to Petrenko.,yes,passed
REQ-3122,2026-11-27,email,Henrik Aalto,h.aalto@aaltolegal.example,I act for Ms Joanna Brandt in a dispute with your company. On behalf of my client I request a copy of all personal data you hold about her.,yes,not done
REQ-3123,2026-11-28,email,Mei-Lin Chow,meilin.chow@mailhaven.example,Please erase all my data. I have moved abroad.,yes,passed
REQ-3124,2026-11-30,email,Callum Reyes,callum.reyes@postbox.example,"Unsubscribe me from offers, and delete all the data you hold about me.",yes,not done
REQ-3125,2026-12-01,web form,Fatima Idrissi,fatima.idrissi@inboxly.example,I'd like to see the data you have about my class bookings.,yes,passed
REQ-3126,2026-12-01,email,Gus Brannigan,gus.brannigan@postbox.example,I am applying for the personal trainer job at your Westfield club. My CV is attached.,no,not done
output/replies.md · written by the agent, 255 lines
Drafts for a person to approve before sending. Not legal advice.

## REQ-3101

Dear Priya,

Reference: REQ-3101

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-11-23.

We are sorry that our answer is late.

## REQ-3102

Dear Tomasz,

Reference: REQ-3102

Before we can act, please send us a copy of a photo ID so that we can confirm who you are.

Our deadline to answer is 2026-11-25.

We are sorry that our answer is late.

## REQ-3103

Dear Edda,

Reference: REQ-3103

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-11-30.

We are sorry that our answer is late.

## REQ-3104

Dear Marcus,

Reference: REQ-3104

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-12-02.

## REQ-3105

Dear Hannah,

Reference: REQ-3105

This is not a personal data request, so we have passed it to our member support team.

## REQ-3106

Dear Katherine,

Reference: REQ-3106

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-12-07.

## REQ-3107

Dear Kathryn,

Reference: REQ-3107

We are already handling this under reference REQ-3106.

Our deadline to answer is 2026-12-07.

## REQ-3108

Dear Ibrahim,

Reference: REQ-3108

We have taken you off our marketing lists.

We are sorry that our answer is late.

## REQ-3109

Dear Dorothy,

Reference: REQ-3109

Before we can act, please send us a signed letter from the person you are writing for.

Our deadline to answer is 2026-12-09.

## REQ-3110

Dear Luca,

Reference: REQ-3110

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-12-14.

## REQ-3111

Dear Selma,

Reference: REQ-3111

We could not find an account under the email address you wrote from.

## REQ-3112

Dear Owen,

Reference: REQ-3112

This is not a personal data request, so we have passed it to our member support team.

## REQ-3113

Dear Grace,

Reference: REQ-3113

Before we can act, please send us a copy of a photo ID so that we can confirm who you are.

Our deadline to answer is 2026-12-17.

## REQ-3114

Dear Tomasz,

Reference: REQ-3114

Before we can act, please send us a copy of a photo ID so that we can confirm who you are.

Our deadline to answer is 2026-12-18.

## REQ-3115

Dear Beatrix,

Reference: REQ-3115

This is not a personal data request, so we have passed it to our member support team.

## REQ-3116

Dear Ibrahim,

Reference: REQ-3116

We are already handling this under reference REQ-3108.

Our deadline to answer is 2026-11-18.

We are sorry that our answer is late.

## REQ-3117

Dear Yusuf,

Reference: REQ-3117

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-12-23.

## REQ-3118

Dear Agnes,

Reference: REQ-3118

Before we can act, please send us a copy of a photo ID so that we can confirm who you are.

## REQ-3119

Dear Rafael,

Reference: REQ-3119

We could not find an account under the email address you wrote from.

## REQ-3120

Dear Priya,

Reference: REQ-3120

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-12-25.

## REQ-3121

Dear Nadia,

Reference: REQ-3121

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-12-28.

## REQ-3122

Dear Henrik,

Reference: REQ-3122

Before we can act, please send us a signed letter from the person you are writing for.

Our deadline to answer is 2026-12-28.

## REQ-3123

Dear Mei-Lin,

Reference: REQ-3123

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-12-28.

## REQ-3124

Dear Callum,

Reference: REQ-3124

Before we can act, please send us a copy of a photo ID so that we can confirm who you are.

Our deadline to answer is 2026-12-30.

## REQ-3125

Dear Fatima,

Reference: REQ-3125

We have confirmed who you are and are working on your request.

Our deadline to answer is 2026-12-31.

## REQ-3126

Dear Gus,

Reference: REQ-3126

This is not a personal data request, so we have passed it to our member support team.
output/request_log.csv · written by the agent, 27 lines
request_id,type,due_date,days_left,timing,reply,duplicate_of,note
REQ-3101,access,2026-11-23,-8,overdue,confirm,,"Access request whose 30-day date fell on a Saturday so it moved to Monday, and it is now overdue."
REQ-3102,delete,2026-11-25,-6,overdue,ask_id,,"Delete request with no ID check done, so the reply asks for photo ID."
REQ-3103,access,2026-11-30,-1,overdue,confirm,,"Access request that also asks who the data was shared with, which the reply does not answer."
REQ-3104,correct,2026-12-02,1,due_soon,confirm,,"Correct request with ID passed, so the reply confirms."
REQ-3105,not_a_request,,,,to_support,,"Billing complaint and refund request, not a personal data request, so it goes to member support."
REQ-3106,access,2026-12-07,6,due_soon,confirm,,"Access request whose 30-day date fell on a Saturday so it moved to Monday, and it is the earlier of two from the same address."
REQ-3107,access,2026-12-07,6,due_soon,duplicate,REQ-3106,"Same email address as REQ-3106 (capital letters ignored, first name spelled Kathryn) five days later, so it is a duplicate and keeps that due date."
REQ-3108,stop_marketing,2026-11-18,-13,overdue,marketing_stopped,,"Stop marketing request whose 10-day date has passed, and a second request from the same address followed."
REQ-3109,access,2026-12-09,8,on_time,ask_authority,,"Access request sent on behalf of the writer's father, so the reply asks for a signed letter."
REQ-3110,delete,2026-12-14,13,on_time,confirm,,"Asks for access and then erasure, so it is logged as delete with access named here."
REQ-3111,delete,2026-12-14,13,on_time,no_account,,Delete request with no account found under this email address.
REQ-3112,not_a_request,,,,to_support,,"Membership cancellation, not a personal data request, so it goes to member support."
REQ-3113,correct,2026-12-17,16,on_time,ask_id,,"Correct request where the ID check failed, so the reply asks for photo ID."
REQ-3114,access,2026-12-18,17,on_time,ask_id,,"Same email address as REQ-3102 but a different type (access, not delete), so it is a new request with its own deadline."
REQ-3115,not_a_request,,,,to_support,,"Question about opening hours, not a personal data request, so it goes to member support."
REQ-3116,stop_marketing,2026-11-18,-13,overdue,duplicate,REQ-3108,"Stop marketing request 12 days after REQ-3108 from the same address, so it is a duplicate that keeps the overdue due date."
REQ-3117,access,2026-12-23,22,on_time,confirm,,"Access request with ID passed, so the reply confirms."
REQ-3118,access,,,no_date,ask_id,,"Access request by post with no received date, so no due date is set and timing is no_date."
REQ-3119,stop_marketing,2026-12-04,3,due_soon,no_account,,"Stop marketing request with no account found, and the no_account reply comes before marketing_stopped in the procedure."
REQ-3120,access,2026-12-25,24,on_time,confirm,,"Same email address as REQ-3101 but 34 days later, which is over 30, so it is a new request with its own deadline."
REQ-3121,correct,2026-12-28,27,on_time,confirm,,"Correct request with ID passed, so the reply confirms."
REQ-3122,access,2026-12-28,27,on_time,ask_authority,,"Access request from a solicitor on behalf of a client, so the reply asks for a signed letter."
REQ-3123,delete,2026-12-28,27,on_time,confirm,,"Delete request with ID passed, so the reply confirms."
REQ-3124,delete,2026-12-30,29,on_time,ask_id,,"Asks to unsubscribe and to delete, so it is logged as delete with stop_marketing named here, and ID is not done."
REQ-3125,access,2026-12-31,30,on_time,confirm,,"Access request received today with ID passed, so the reply confirms."
REQ-3126,not_a_request,,,,to_support,,"Job application, not a personal data request, so it goes to member support."
check.py · the check, written before the run
"""Applies the written procedure to every message again, then compares the log and the drafted replies with that."""
import csv, re, sys
from datetime import date, timedelta
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):
    s = (s or "").replace("“", '"').replace("”", '"').replace("’", "'").replace("‘", "'")
    return re.sub(r"\s+", " ", s).strip()
def day(s):
    m = re.fullmatch(r"(\d{4})-(\d{2})-(\d{2})", (s or "").strip())
    return date(*map(int, m.groups())) if m else None

today = day((root / "input/as_of.txt").read_text())
src = list(csv.DictReader((root / "input/requests.csv").open(newline="")))
# The procedure's definitions of each type, in the procedure's own order.
TYPES = [
    ("delete", r"\b(delete|erase)\b"),
    ("access", r"\bcopy of\b|what (information|data|personal data) (do )?you (have|hold)|everything you hold|see the data"),
    ("correct", r"\b(correct|update|fix)\b"),
    ("stop_marketing", r"mailing list|marketing|promotional|unsubscribe"),
]
def kind_of(message):
    return next((name for name, pattern in TYPES if re.search(pattern, message, re.I)), "not_a_request")

want = {}
for r in sorted(src, key=lambda r: (r["received_date"] or "9999", r["request_id"])):
    rid, typ, got_on = r["request_id"], kind_of(r["message"]), day(r["received_date"])
    due = None
    if typ != "not_a_request" and got_on:
        due = got_on + timedelta(days=10 if typ == "stop_marketing" else 30)
        due += timedelta(days={5: 2, 6: 1}.get(due.weekday(), 0))
    dup = None
    if typ != "not_a_request" and got_on:
        for other, w in want.items():
            if (w["email"] == r["email"].lower() and w["type"] == typ and w["received"] and not w["dup"]
                    and 0 <= (got_on - w["received"]).days <= 30):
                dup = other; due = w["due"]; break
    if typ == "not_a_request": reply = "to_support"
    elif dup: reply = "duplicate"
    elif r["account_match"].strip().lower() == "no": reply = "no_account"
    elif typ == "stop_marketing": reply = "marketing_stopped"
    elif re.search(r"on behalf of", r["message"], re.I): reply = "ask_authority"
    elif r["id_check"].strip().lower() != "passed": reply = "ask_id"
    else: reply = "confirm"
    left = (due - today).days if due else None
    timing = "" if typ == "not_a_request" else "no_date" if not got_on else "overdue" if left < 0 else "due_soon" if left <= 7 else "on_time"
    want[rid] = {"type": typ, "received": got_on, "due": due, "left": left, "timing": timing, "reply": reply, "dup": dup,
                 "email": r["email"].lower(), "first": r["name"].split()[0]}

path = root / "output/request_log.csv"
if not path.exists():
    say(False, "output/request_log.csv was not written"); sys.exit(1)
got = {}
for r in csv.DictReader(path.open(newline="")):
    got.setdefault((r.get("request_id") or "").strip(), []).append(r)
once = sum(1 for k in want if len(got.get(k, [])) == 1)
row = {k: (got.get(k) or [{}])[0] for k in want}
cell = lambda k, col: norm(row[k].get(col))
# The flow asks for a note of one plain sentence: some words and at most one sentence end.
short = sum(1 for k in want if cell(k, "note") and len(re.findall(r"[.!?](?=\s|$)", cell(k, "note"))) <= 1)
say(once == len(want) and set(got) == set(want) and short == len(want),
    f"{once} of {len(want)} messages are logged exactly once, and {short} of {len(want)} notes are one sentence")

types = sum(1 for k, w in want.items() if cell(k, "type") == w["type"])
real = sum(1 for w in want.values() if w["type"] != "not_a_request")
say(types == len(want), f"{types} of {len(want)} types equal the type the procedure gives for the message ({real} data requests, {len(want) - real} not a request)")

def dates_ok(k):
    w = want[k]
    if not w["due"]:
        return not cell(k, "due_date") and not cell(k, "days_left") and cell(k, "timing") == w["timing"]
    return day(cell(k, "due_date")) == w["due"] and cell(k, "days_left") == str(w["left"]) and cell(k, "timing") == w["timing"]
dated = sum(1 for k in want if dates_ok(k))
late = sum(1 for w in want.values() if w["timing"] == "overdue")
say(dated == len(want), f"{dated} of {len(want)} due dates, days left and timings equal the values worked out from the received date ({late} overdue)")

kinds = sum(1 for k, w in want.items() if cell(k, "reply") == w["reply"] and cell(k, "duplicate_of") == (w["dup"] or ""))
dups = sum(1 for w in want.values() if w["dup"])
say(kinds == len(want), f"{kinds} of {len(want)} reply kinds equal the first one that applies in the procedure, and {dups} repeats point at the right earlier request")

text = (root / "output/replies.md").read_text() if (root / "output/replies.md").exists() else ""
parts = re.split(r"^##\s+.*?(REQ-\d+).*$", text, flags=re.M)
draft = {parts[i]: norm(re.sub(r"[*_>]", "", parts[i + 1])) for i in range(1, len(parts), 2)}  # bold and quote marks do not count
SENTENCE = {
    "to_support": "This is not a personal data request, so we have passed it to our member support team.",
    "no_account": "We could not find an account under the email address you wrote from.",
    "marketing_stopped": "We have taken you off our marketing lists.",
    "ask_authority": "Before we can act, please send us a signed letter from the person you are writing for.",
    "ask_id": "Before we can act, please send us a copy of a photo ID so that we can confirm who you are.",
    "confirm": "We have confirmed who you are and are working on your request.",
}
def worded(k):
    w, d = want[k], draft.get(k, "")
    need = SENTENCE.get(w["reply"]) or f"We are already handling this under reference {w['dup']}."
    others = [s for name, s in SENTENCE.items() if name != w["reply"]]
    return (re.search(r"Dear " + re.escape(w["first"]) + r"\b", d) is not None and re.search(r"Reference: ?" + k + r"\b", d) is not None
            and need in d and not any(s in d for s in others))
good = sum(1 for k in want if worded(k))
say(good == len(want), f"{good} of {len(want)} drafts greet the right person, carry the reference and hold the approved sentence for their kind and no other")

owes = [k for k, w in want.items() if w["reply"] in ("duplicate", "ask_authority", "ask_id", "confirm") and w["due"]]
def deadline_ok(k):
    said = re.findall(r"Our deadline to answer is (\d{4}-\d{2}-\d{2})\.", draft.get(k, ""))
    return said == ([want[k]["due"].isoformat()] if k in owes else [])
dl = sum(1 for k in want if deadline_ok(k))
sorry = sum(1 for k, w in want.items() if ("We are sorry that our answer is late." in draft.get(k, "")) == (w["timing"] == "overdue"))
say(dl == len(want) and sorry == len(want),
    f"{len(owes) if dl == len(want) else sum(1 for k in owes if deadline_ok(k))} of {len(owes)} drafts that owe a deadline state the right date, "
    f"and the apology appears in {late if sorry == len(want) else sum(1 for k, w in want.items() if w['timing'] == 'overdue' and 'We are sorry that our answer is late.' in draft.get(k, ''))} of {late} overdue drafts and nowhere else")

first = next((ln.strip() for ln in text.splitlines() if ln.strip()), "")
say(first == "Drafts for a person to approve before sending. Not legal advice.", "replies.md opens by saying these are drafts for a person to approve and not legal advice")
sys.exit(0 if ok else 1)

as_of.txt: sample data written by Atris. Fingerprint d3346a60677d.

procedure.md: sample data written by Atris. Fingerprint 6fccd4147092.

requests.csv: sample data written by Atris. Fingerprint b489aaa12894.

replies.md: written by the agent. Fingerprint 76bee945cc86.

request_log.csv: written by the agent. Fingerprint f047e343ea10.


More contracts and compliance work, and every other desk job

For agentsGitHub
What is AtrisBlogApp StorePricingPrivacyTerms