Build a trip plan with no clashes.
Done by an agent. Checked twice.
Flights and a meeting agenda for a three city week, with every must meeting placed and no clash or broken travel limit.
Real files in
- flights.csv
Nine flight options across the three legs of the trip, in local times. 10 lines, 539 bytes. - meeting_requests.csv
27 meeting requests for one travel week, in person and by video, with a repeated request, one with no length and several that cannot fit. 28 lines, 3 KB. - requests_note.md
A short note on how to read the meeting request columns. 7 lines, 389 bytes. - time_zones.csv
The UTC offset in December for the seven cities in the requests. 8 lines, 101 bytes. - travel_limits.md
The executive's written travel limits: route, flight rules, time around flights, working hours and meeting gaps. 28 lines, 1 KB.
Sample data written by Atris. Not a real company.
Three steps
- 1.Read the requests and the limits
- 2.Choose the flights and place the meetings
- 3.Write the plan and the agenda
Claude Sonnet 5.5, 13 min 7 s. No web. It never saw the check.
Checked twice
- Passed: 27 of 27 requests appear once in agenda.csv with a status and 11 of 11 not scheduled leave city and times blank. agenda.md shows 16 of 16 scheduled meetings and 3 of 3 flights with the times in the csv files
- Passed: 3 of 3 rows of trip_plan.csv copy the flight list in leg order, connect Denver, Chicago, New York and Denver and break none of the 3 flight limits
- Passed: 16 of 16 scheduled meetings sit inside the requester's window, the working hours and the right city, clear of every flight
- Passed: 0 pairs of meetings clash or sit closer than 30 minutes and 0 days hold more than 5
- Passed: 16 of 16 scheduled meetings show UTC times equal to the local times converted with the time zone file
- Passed: 9 of 9 must requests are scheduled, 1 of 1 repeated requests are marked duplicate, 1 of 1 with no length are marked needs_info and 0 other requests carry those two marks
- Passed: 64 of 64 clock times in agenda.md are on the quarter hour, printed in an input file or the edge of the closed time around a chosen flight
- Passed: 16 of 16 meetings in agenda.md sit under the line for their own day
- Passed: 0 of 9 declined requests could still be added to the agenda without breaking a limit
Second review by Claude Opus 5.5: pass.
Then we broke a copy of the output 8 ways on purpose. The check caught 8.
## Tuesday December 08, 2026 - 08:00-08:30 R-20, Alistair Penrose, Thameside Automation, video (Chicago time) - 09:00-10:00 R-01, Mirela Santoro, Calloway Freight, in person (Chicago time) - 13:00-14:30 R-04, Dr. Ansel Whitcombe, Lakeshore Robotics Lab, in person (Chicago time) - 16:30-17:30 R-05, Roxana Villanueva, Great Plains Distributors, in person (Chicago time) - 18:00-18:30 R-25, Imogen Takahashi, Presidio Systems, video (Chicago time) ## Wednesday December 09, 2026 - 11:45-12:30 R-21, Mei-Lin Carrow, Baywater Capital, video (New York time) - 14:00-15:00 R-10, Evander Brook, Hudson Meridian Bank, in person (New York time) - 16:00-16:45 R-16, Rohan Seidel, East River Ventures, in person (New York time)
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 2 of 2 on 1 December 2026. The agent took 13 min 7 s. 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
- Each leg could only use one flight. F-02 is the only legal first flight: F-01 leaves at 06:15 and F-03 is on Sunday. F-04 would close time from 17:10 and clash with must R-05 (16:30-17:30). F-06 would leave him in Chicago during must R-10 in New York. F-07 would close time from 16:45 and clash with must R-11. F-09 lands at 20:15, after the noon limit.
- I recomputed every UTC time with the offsets in time_zones.csv and all are correct. For example, R-25 at 18:00 Chicago is 2026-12-09T00:00 UTC (17:30-19:00 Chicago in the San Francisco window). R-21 at 11:45 New York is 08:45 San Francisco, inside its 08:00-10:00 window. R-23 at 08:00 New York is 13:00 London.
- Closed time around flights is applied correctly. After F-02 lands at 14:55 he is free from 16:25, so R-06 at 16:30 is fine and only one of R-06 and R-08 can fit. After F-05 lands at 10:15 he is free from 11:45, so R-21 at 11:45 is fine and R-15 (10:00-11:30) cannot fit.
- Days that hit the cap stay within the rules. Dec 8 has 5 meetings (R-20, R-01, R-04, R-05, R-25) and Dec 10 has 5 (R-23, R-12, R-13, R-14, R-11). Every gap is at least 30 minutes and all times are inside the in-person and video hours. R-02 and R-27 correctly stay declined because of the 5-a-day limit.
What this run does not show
- The travel limits were copied by hand from the limits file into the check before the run. If the file changed, the check would need the same change.
- The check proves no declined request could be added to this agenda. It does not prove this agenda holds the most meetings possible.
- Reasons for declining are free text. Their clock times are tested only loosely, so a wrong hour in a reason can get through.
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 8 of 8. 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
# Build a trip plan with no clashes function: leadership for: the assistant who plans an executive's travel week goal: The executive has flights and a day by day agenda where every meeting fits the other person's hours, the travel limits and the clock, and nothing overlaps. ## 1. Read the requests and the limits Read input/travel_limits.md, input/requests_note.md, input/meeting_requests.csv, input/flights.csv and input/time_zones.csv. Every limit in travel_limits.md is a hard rule. Before placing anything: - A request with the same person, company, kind, city, length and window as an earlier request is a repeat. Give the later one status `duplicate`. - A request with no length or no window cannot be placed. Give it status `needs_info`. - Turn every window into UTC with time_zones.csv. A window is in the local time of the request's city. ## 2. Choose the flights and place the meetings Choose one flight for each leg of the route so that no flight limit is broken and every `must` request can be placed. Then place meetings: - Place every must request first. Then place as many want requests as fit. - A meeting is placed only when it breaks no limit: the window, the working hours by the clock of the city the executive is in, the right city for a meeting in person, the closed time around each flight, the gap between meetings and the most meetings in a day. - Give status `declined` to a request that cannot be placed, and say which limit stops it. - When you finish, test each declined request once more against the finished agenda. If it could still be added at some start time without breaking a limit, add it. Use python3 for the time arithmetic. Do not work out time zones in your head. ## 3. Write the plan and the agenda Write output/trip_plan.csv with columns leg,flight_id,from,to,depart_local,arrive_local. One row for each leg, in order. Write output/agenda.csv with columns request_id,status,city,local_start,local_end,utc_start,utc_end,reason. One row for each request. status is scheduled, declined, duplicate or needs_info. For a scheduled request, city is the city the executive is in, local times are by that city's clock, and all four times are written like 2026-12-08T09:00. For any other status leave city and the times blank and give the reason in one plain sentence. Write output/agenda.md: the flights, one line each with the flight_id and its local departure and arrival times. Then each day in order with one line for each meeting: its local start and end times written like 09:00, the request_id, the person, the company and whether it is in person or by video. The times must be the ones in the two csv files. End with the list of requests that were not scheduled and why. ## Done looks like - Every request appears once in agenda.csv with a status. - Every must request is scheduled and no two meetings clash. - No declined request could still be added without breaking a limit.
input/flights.csv · 10 lines, 539 bytes
flight_id,from,to,depart_local,arrive_local F-01,Denver,Chicago,2026-12-07T06:15,2026-12-07T09:40 F-02,Denver,Chicago,2026-12-07T11:30,2026-12-07T14:55 F-03,Denver,Chicago,2026-12-06T18:20,2026-12-06T21:45 F-04,Chicago,New York,2026-12-08T19:10,2026-12-08T22:25 F-05,Chicago,New York,2026-12-09T07:00,2026-12-09T10:15 F-06,Chicago,New York,2026-12-09T13:30,2026-12-09T16:45 F-07,New York,Denver,2026-12-10T18:45,2026-12-10T21:30 F-08,New York,Denver,2026-12-11T08:10,2026-12-11T10:55 F-09,New York,Denver,2026-12-11T17:30,2026-12-11T20:15
input/meeting_requests.csv · 28 lines, 3 KB
request_id,person,company,kind,city,duration_min,window_start,window_end,priority,note R-01,Mirela Santoro,Calloway Freight,in_person,Chicago,60,2026-12-08T09:00,2026-12-08T12:00,must,Contract renewal talk R-02,Desmond Achebe,Ironvale Packaging,in_person,Chicago,45,2026-12-08T09:00,2026-12-08T11:00,want,Wants a demo of the new arm R-03,Petra Lindholm,Pinecrest Capital,in_person,Denver,45,2026-12-07T08:00,2026-12-07T10:00,must,Breakfast before he leaves R-04,Dr. Ansel Whitcombe,Lakeshore Robotics Lab,in_person,Chicago,90,2026-12-08T13:00,2026-12-08T17:00,want,Lab tour R-05,Roxana Villanueva,Great Plains Distributors,in_person,Chicago,60,2026-12-08T16:30,2026-12-08T17:30,must,Only slot her chief executive has R-06,Tobiah Marsh,Halsted Tooling,in_person,Chicago,30,2026-12-07T15:00,2026-12-07T18:00,want,Supplier catch up R-07,Ingeborg Dahl,Wabash Cold Storage,in_person,Chicago,60,2026-12-09T09:00,2026-12-09T11:00,want,Site visit R-08,Carmine Okafor,Prairie Works,in_person,Chicago,45,2026-12-07T16:00,2026-12-07T17:30,want,Possible pilot customer R-09,Mirela Santoro,Calloway Freight,in_person,Chicago,60,2026-12-08T09:00,2026-12-08T12:00,must,Sent again by her assistant R-10,Evander Brook,Hudson Meridian Bank,in_person,New York,60,2026-12-09T14:00,2026-12-09T16:00,must,Credit line review R-11,Saskia Morgenthau,Bleecker Automation,in_person,New York,60,2026-12-10T16:30,2026-12-10T17:30,must,"Partnership terms, her only free hour" R-12,Lionel Baptiste,Tribeca Logistics Fund,in_person,New York,45,2026-12-10T09:00,2026-12-10T12:00,must,Investor meeting R-13,Noor Castellane,Gansevoort Design,in_person,New York,60,2026-12-10T10:00,2026-12-10T12:00,want,Packaging redesign R-14,Felix Abernathy,Castle Hill Robotics Meetup,in_person,New York,90,2026-12-10T12:30,2026-12-10T14:30,want,Lunch talk to founders R-15,Marguerite Osei,Bowery Sensors,in_person,New York,30,2026-12-09T10:00,2026-12-09T11:30,want,Coffee R-16,Rohan Seidel,East River Ventures,in_person,New York,45,2026-12-09T16:00,2026-12-09T18:00,want,First meeting R-17,Clementine Rourke,Morningside Supply,in_person,New York,,2026-12-10T13:00,2026-12-10T17:00,want,Did not say how long R-18,Augustin Farrow,Beacon Street Partners,in_person,Boston,60,2026-12-10T09:00,2026-12-10T17:00,want,Asks him to come up for the day R-19,Henrietta Vale,Fulton Dock Co,in_person,New York,60,2026-12-11T09:00,2026-12-11T11:00,want,Warehouse walk through R-20,Alistair Penrose,Thameside Automation,video,London,30,2026-12-08T14:00,2026-12-08T17:00,must,Distributor for the United Kingdom R-21,Mei-Lin Carrow,Baywater Capital,video,San Francisco,45,2026-12-09T08:00,2026-12-09T10:00,must,Board member check in R-22,Dalton Reyes,Lonestar Fulfillment,video,Austin,30,2026-12-07T07:00,2026-12-07T09:00,want,Quick intro R-23,Oriel Hathersage,Greywell Robotics,video,London,60,2026-12-10T13:00,2026-12-10T15:00,want,Research partnership R-24,Hollowbrook leadership team,Hollowbrook Robotics,video,Denver,60,2026-12-11T13:00,2026-12-11T16:00,must,Weekly staff call R-25,Imogen Takahashi,Presidio Systems,video,San Francisco,30,2026-12-08T15:30,2026-12-08T17:00,want,Software vendor R-26,Bartholomew Quince,Astoria Mechanical,video,New York,30,2026-12-12T10:00,2026-12-12T12:00,want,Only free on Saturday R-27,Yolanda Petrakis,Cermak Electric,in_person,Chicago,45,2026-12-08T11:00,2026-12-08T14:00,want,Wiring supplier
input/requests_note.md · 7 lines, 389 bytes
# How to read meeting_requests.csv - kind is in_person or video. - For a meeting in person, city is where the meeting would take place. - For a video call, city is where the other person is. - window_start and window_end are in the local time of that city. The whole meeting must fall inside the window. - priority is must or want. A must is a meeting Leander has said cannot be dropped.
input/time_zones.csv · 8 lines, 101 bytes
city,utc_offset_hours Denver,-7 Chicago,-6 Austin,-6 New York,-5 Boston,-5 San Francisco,-8 London,0
input/travel_limits.md · 28 lines, 1 KB
# Travel limits for Leander Voss, week of December 7, 2026 Leander Voss is the founder of Hollowbrook Robotics. He lives in Denver. This note is kept by his assistant and applies to every trip unless he says otherwise. ## This trip - Route: Denver to Chicago to New York and back to Denver. One flight for each of the three legs, chosen from flights.csv. Flight times in that file are local to the city of departure or arrival. - Meetings can be on Monday December 7 to Friday December 11 only, by the date where Leander is. ## Flights - He does not fly on Sundays. - No flight that departs before 07:00 local time. - He must land in Denver before 12:00 on Friday December 11, Denver time. ## Around a flight - Nothing can be scheduled from 120 minutes before a flight departs until 90 minutes after it lands. This covers video calls as well as meetings in person. - Before the first flight departs he is in Denver. After a flight lands he is in the city it landed in. ## Meetings - A meeting in person must be in the city where Leander is at that time. - Meetings in person start no earlier than 08:30 and end no later than 18:00, local time. - Video calls start no earlier than 08:00 and end no later than 19:00, by the clock of the city where Leander is at that time. - Leave at least 30 minutes between the end of one meeting or call and the start of the next. - No more than 5 meetings and calls on one day. - Start times are on the quarter hour: :00, :15, :30 or :45.
output/agenda.csv · written by the agent, 28 lines
request_id,status,city,local_start,local_end,utc_start,utc_end,reason R-01,scheduled,Chicago,2026-12-08T09:00,2026-12-08T10:00,2026-12-08T15:00,2026-12-08T16:00, R-02,declined,,,,,,"Chicago on Dec 8 already holds the 5 meetings a day allowed (R-20, R-01, R-04, R-05, R-25), so no start time in its 09:00-11:00 window is open." R-03,scheduled,Denver,2026-12-07T08:30,2026-12-07T09:15,2026-12-07T15:30,2026-12-07T16:15, R-04,scheduled,Chicago,2026-12-08T13:00,2026-12-08T14:30,2026-12-08T19:00,2026-12-08T20:30, R-05,scheduled,Chicago,2026-12-08T16:30,2026-12-08T17:30,2026-12-08T22:30,2026-12-08T23:30, R-06,scheduled,Chicago,2026-12-07T16:30,2026-12-07T17:00,2026-12-07T22:30,2026-12-07T23:00, R-07,declined,,,,,,"On Dec 9 he is on the 07:00 flight F-05 from Chicago, so he is not in Chicago during its 09:00-11:00 window." R-08,declined,,,,,,"Its only possible starts (16:30 or 16:45 on Dec 7) fall within 30 minutes of R-06, which is placed at 16:30-17:00; he lands at 14:55 and nothing can start before 16:25." R-09,duplicate,,,,,,"Repeat of R-01 (same person, company, kind, city, length and window)." R-10,scheduled,New York,2026-12-09T14:00,2026-12-09T15:00,2026-12-09T19:00,2026-12-09T20:00, R-11,scheduled,New York,2026-12-10T16:30,2026-12-10T17:30,2026-12-10T21:30,2026-12-10T22:30, R-12,scheduled,New York,2026-12-10T09:30,2026-12-10T10:15,2026-12-10T14:30,2026-12-10T15:15, R-13,scheduled,New York,2026-12-10T10:45,2026-12-10T11:45,2026-12-10T15:45,2026-12-10T16:45, R-14,scheduled,New York,2026-12-10T12:30,2026-12-10T14:00,2026-12-10T17:30,2026-12-10T19:00, R-15,declined,,,,,,Its 10:00-11:30 window on Dec 9 falls inside the closed time after F-05 lands at 10:15 (closed until 11:45). R-16,scheduled,New York,2026-12-09T16:00,2026-12-09T16:45,2026-12-09T21:00,2026-12-09T21:45, R-17,needs_info,,,,,,"No meeting length was given, so it cannot be placed." R-18,declined,,,,,,"Boston is not on the route (Denver, Chicago, New York, Denver), and no flight to Boston is in flights.csv." R-19,declined,,,,,,"He leaves New York on F-08 at 08:10 on Dec 11 (closed from 06:10), so he is not in New York during its 09:00-11:00 window." R-20,scheduled,Chicago,2026-12-08T08:00,2026-12-08T08:30,2026-12-08T14:00,2026-12-08T14:30, R-21,scheduled,New York,2026-12-09T11:45,2026-12-09T12:30,2026-12-09T16:45,2026-12-09T17:30, R-22,declined,,,,,,"The 07:00-09:00 Austin window is 06:00-08:00 Denver time, and video calls cannot start before 08:00 where he is." R-23,scheduled,New York,2026-12-10T08:00,2026-12-10T09:00,2026-12-10T13:00,2026-12-10T14:00, R-24,scheduled,Denver,2026-12-11T13:00,2026-12-11T14:00,2026-12-11T20:00,2026-12-11T21:00, R-25,scheduled,Chicago,2026-12-08T18:00,2026-12-08T18:30,2026-12-09T00:00,2026-12-09T00:30, R-26,declined,,,,,,"It is on Saturday Dec 12, and meetings can only be Monday Dec 7 to Friday Dec 11." R-27,declined,,,,,,"Chicago on Dec 8 already holds the 5 meetings a day allowed, so no start time in its 11:00-14:00 window is open."
output/agenda.md · written by the agent, 45 lines
# Trip agenda for Leander Voss, December 7 to 11, 2026 ## Flights - F-02: Denver to Chicago, departs 2026-12-07T11:30, arrives 2026-12-07T14:55 (local times) - F-05: Chicago to New York, departs 2026-12-09T07:00, arrives 2026-12-09T10:15 (local times) - F-08: New York to Denver, departs 2026-12-11T08:10, arrives 2026-12-11T10:55 (local times) ## Monday December 07, 2026 - 08:30-09:15 R-03, Petra Lindholm, Pinecrest Capital, in person (Denver time) - 16:30-17:00 R-06, Tobiah Marsh, Halsted Tooling, in person (Chicago time) ## Tuesday December 08, 2026 - 08:00-08:30 R-20, Alistair Penrose, Thameside Automation, video (Chicago time) - 09:00-10:00 R-01, Mirela Santoro, Calloway Freight, in person (Chicago time) - 13:00-14:30 R-04, Dr. Ansel Whitcombe, Lakeshore Robotics Lab, in person (Chicago time) - 16:30-17:30 R-05, Roxana Villanueva, Great Plains Distributors, in person (Chicago time) - 18:00-18:30 R-25, Imogen Takahashi, Presidio Systems, video (Chicago time) ## Wednesday December 09, 2026 - 11:45-12:30 R-21, Mei-Lin Carrow, Baywater Capital, video (New York time) - 14:00-15:00 R-10, Evander Brook, Hudson Meridian Bank, in person (New York time) - 16:00-16:45 R-16, Rohan Seidel, East River Ventures, in person (New York time) ## Thursday December 10, 2026 - 08:00-09:00 R-23, Oriel Hathersage, Greywell Robotics, video (New York time) - 09:30-10:15 R-12, Lionel Baptiste, Tribeca Logistics Fund, in person (New York time) - 10:45-11:45 R-13, Noor Castellane, Gansevoort Design, in person (New York time) - 12:30-14:00 R-14, Felix Abernathy, Castle Hill Robotics Meetup, in person (New York time) - 16:30-17:30 R-11, Saskia Morgenthau, Bleecker Automation, in person (New York time) ## Friday December 11, 2026 - 13:00-14:00 R-24, Hollowbrook leadership team, Hollowbrook Robotics, video (Denver time) ## Not scheduled - R-02 (declined): Chicago on Dec 8 already holds the 5 meetings a day allowed (R-20, R-01, R-04, R-05, R-25), so no start time in its 09:00-11:00 window is open. - R-07 (declined): On Dec 9 he is on the 07:00 flight F-05 from Chicago, so he is not in Chicago during its 09:00-11:00 window. - R-08 (declined): Its only possible starts (16:30 or 16:45 on Dec 7) fall within 30 minutes of R-06, which is placed at 16:30-17:00; he lands at 14:55 and nothing can start before 16:25. - R-09 (duplicate): Repeat of R-01 (same person, company, kind, city, length and window). - R-15 (declined): Its 10:00-11:30 window on Dec 9 falls inside the closed time after F-05 lands at 10:15 (closed until 11:45). - R-17 (needs_info): No meeting length was given, so it cannot be placed. - R-18 (declined): Boston is not on the route (Denver, Chicago, New York, Denver), and no flight to Boston is in flights.csv. - R-19 (declined): He leaves New York on F-08 at 08:10 on Dec 11 (closed from 06:10), so he is not in New York during its 09:00-11:00 window. - R-22 (declined): The 07:00-09:00 Austin window is 06:00-08:00 Denver time, and video calls cannot start before 08:00 where he is. - R-26 (declined): It is on Saturday Dec 12, and meetings can only be Monday Dec 7 to Friday Dec 11. - R-27 (declined): Chicago on Dec 8 already holds the 5 meetings a day allowed, so no start time in its 11:00-14:00 window is open.
output/trip_plan.csv · written by the agent, 4 lines
leg,flight_id,from,to,depart_local,arrive_local 1,F-02,Denver,Chicago,2026-12-07T11:30,2026-12-07T14:55 2,F-05,Chicago,New York,2026-12-09T07:00,2026-12-09T10:15 3,F-08,New York,Denver,2026-12-11T08:10,2026-12-11T10:55
check.py · the check, written before the run
"""Tests the trip plan and agenda against every travel limit, time zone and request window in the input files."""
import csv, re, sys
from datetime import datetime, timedelta
from pathlib import Path
# The limits below are the ones written in input/travel_limits.md.
HOME, ROUTE = "Denver", ["Denver", "Chicago", "New York", "Denver"]
FIRST_DAY, LAST_DAY = "2026-12-07", "2026-12-11"
GAP, PER_DAY, BEFORE, AFTER = 30, 5, 120, 90
def t(s):
return datetime.strptime(re.sub(r"[ T]", "T", (s or "").strip())[:16], "%Y-%m-%dT%H:%M")
def load(root):
tz = {r["city"]: float(r["utc_offset_hours"]) for r in csv.DictReader((root/"input/time_zones.csv").open())}
flights = {r["flight_id"]: r for r in csv.DictReader((root/"input/flights.csv").open())}
reqs = list(csv.DictReader((root/"input/meeting_requests.csv").open()))
return tz, flights, reqs
def utc(local, city, tz): return local - timedelta(hours=tz[city])
def local(u, city, tz): return u + timedelta(hours=tz[city])
def flight_problems(ids, flights, tz):
"""Why the chosen flights break the route or the flight limits. Empty when they are fine."""
if len(ids) != 3 or any(i not in flights for i in ids): return ["three flights from the flight list are needed"]
out, prev = [], None
for leg, i in enumerate(ids):
f = flights[i]; dep, arr = t(f["depart_local"]), t(f["arrive_local"])
if (f["from"], f["to"]) != (ROUTE[leg], ROUTE[leg + 1]): out.append(f"{i} is not the {ROUTE[leg]} to {ROUTE[leg + 1]} leg")
if dep.weekday() == 6 or arr.weekday() == 6: out.append(f"{i} flies on a Sunday")
if dep.strftime("%H:%M") < "07:00": out.append(f"{i} departs before 07:00")
if prev and utc(dep, f["from"], tz) < prev: out.append(f"{i} departs before the earlier flight lands")
prev = utc(arr, f["to"], tz)
if not out and t(flights[ids[2]]["arrive_local"]) >= t("2026-12-11T12:00"): out.append("lands in Denver after 12:00 on Friday")
return out
def where(u, ids, flights, tz):
"""The city he is in at a UTC time, or None inside the closed time around a flight."""
city = HOME
for i in ids:
f = flights[i]; dep, arr = utc(t(f["depart_local"]), f["from"], tz), utc(t(f["arrive_local"]), f["to"], tz)
if dep - timedelta(minutes=BEFORE) < u < arr + timedelta(minutes=AFTER): return None
if u >= arr + timedelta(minutes=AFTER): city = f["to"]
return city
def slot_problem(req, start_utc, ids, flights, tz):
"""Why this request cannot start at this UTC time, looking at the request and the flights only."""
end_utc = start_utc + timedelta(minutes=int(req["duration_min"]))
a, b = where(start_utc, ids, flights, tz), where(end_utc, ids, flights, tz)
mid = [where(start_utc + timedelta(minutes=m), ids, flights, tz) for m in range(0, int(req["duration_min"]) + 1, 15)]
if a is None or b is None or any(m != a for m in mid): return "inside the closed time around a flight"
ls, le = local(start_utc, a, tz), local(end_utc, a, tz)
if not (FIRST_DAY <= ls.strftime("%Y-%m-%d") <= LAST_DAY): return "outside the trip dates"
if ls.minute % 15: return "not on the quarter hour"
if req["kind"] == "in_person" and req["city"] != a: return f"he is in {a}, not {req['city']}"
lo, hi = ("08:30", "18:00") if req["kind"] == "in_person" else ("08:00", "19:00")
if ls.strftime("%H:%M") < lo or le.strftime("%H:%M") > hi or le.date() != ls.date(): return "outside working hours"
ws, we = utc(t(req["window_start"]), req["city"], tz), utc(t(req["window_end"]), req["city"], tz)
if start_utc < ws or end_utc > we: return "outside the requester's window"
return None
def clash(placed, start_utc, end_utc, day):
"""True when a new meeting would sit closer than the gap to another or overfill the day."""
if sum(1 for _, _, d in placed if d == day) >= PER_DAY: return True
return any(start_utc < e + timedelta(minutes=GAP) and s < end_utc + timedelta(minutes=GAP) for s, e, _ in placed)
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)
tz, flights, reqs = load(root)
byid = {r["request_id"]: r for r in reqs}
apath, ppath = root/"output/agenda.csv", root/"output/trip_plan.csv"
if not apath.exists() or not ppath.exists():
say(False, "output/agenda.csv and output/trip_plan.csv were not both written"); sys.exit(1)
rows = list(csv.DictReader(apath.open())); got = {(r.get("request_id") or "").strip(): r for r in rows}
ids = [(r.get("flight_id") or "").strip() for r in csv.DictReader(ppath.open())]
status = {k: (got.get(k, {}).get("status") or "").strip() for k in byid}
once = sum(1 for k in byid if sum(1 for r in rows if (r.get("request_id") or "").strip() == k) == 1
and status[k] in ("scheduled", "declined", "duplicate", "needs_info"))
md = (root/"output/agenda.md").read_text() if (root/"output/agenda.md").exists() else ""
def shown(key, a, b):
"""True when a line of agenda.md names this id with both clock times."""
try: a, b = t(a).strftime("%H:%M"), t(b).strftime("%H:%M")
except ValueError: return False
return any((re.search(r"\b[RF]-\d+\b", ln) or [""])[0] == key and a in ln and b in ln for ln in md.splitlines())
listed = [k for k in byid if status[k] == "scheduled" and shown(k, got[k].get("local_start"), got[k].get("local_end"))]
n_sched = sum(1 for k in byid if status[k] == "scheduled")
prows = list(csv.DictReader(ppath.open()))
f_shown = sum(1 for i in ids if i in flights and shown(i, flights[i]["depart_local"], flights[i]["arrive_local"]))
rest = [k for k in byid if status[k] in ("declined", "duplicate", "needs_info")]
bare = sum(1 for k in rest if not any((got[k].get(c) or "").strip() for c in ("city", "local_start", "local_end", "utc_start", "utc_end")))
say(once == len(byid) and len(rows) == len(byid) and len(listed) == n_sched and f_shown == len(ROUTE) - 1 and bare == len(rest),
f"{once} of {len(byid)} requests appear once in agenda.csv with a status and {bare} of {len(rest)} not scheduled leave city and times blank. agenda.md shows {len(listed)} of {n_sched} scheduled meetings and {f_shown} of {len(ROUTE) - 1} flights with the times in the csv files")
fp = flight_problems(ids, flights, tz)
def copied(n, r):
f = flights.get((r.get("flight_id") or "").strip())
try: return bool(f) and (r.get("leg") or "").strip() == str(n) and all((r.get(c) or "").strip() == f[c] for c in ("from", "to")) \
and all(t(r.get(c)) == t(f[c]) for c in ("depart_local", "arrive_local"))
except ValueError: return False
cp = sum(1 for n, r in enumerate(prows, 1) if copied(n, r))
say(not fp and cp == len(ROUTE) - 1, f"{cp} of 3 rows of trip_plan.csv copy the flight list in leg order, connect Denver, Chicago, New York and Denver and break none of the 3 flight limits" if not fp else "flights: " + "; ".join(fp))
if fp: ids = []
sched, good, conv, placed = [k for k in byid if status[k] == "scheduled"], 0, 0, []
for k in sched:
r, g = byid[k], got[k]
try:
ls, le, us, ue = t(g.get("local_start")), t(g.get("local_end")), t(g.get("utc_start")), t(g.get("utc_end"))
city = where(us, ids, flights, tz) if ids else None
fine = bool(ids) and r["duration_min"].strip() != "" and slot_problem(r, us, ids, flights, tz) is None \
and ue - us == timedelta(minutes=int(r["duration_min"])) and (g.get("city") or "").strip() == city
good += fine
conv += bool(city) and utc(ls, city, tz) == us and utc(le, city, tz) == ue
placed.append((us, ue, local(us, city, tz).date() if city else us.date()))
except (ValueError, KeyError, TypeError): pass
say(bool(sched) and good == len(sched), f"{good} of {len(sched)} scheduled meetings sit inside the requester's window, the working hours and the right city, clear of every flight")
close = sum(1 for i, a in enumerate(placed) for b in placed[i + 1:] if a[0] < b[1] + timedelta(minutes=GAP) and b[0] < a[1] + timedelta(minutes=GAP))
full = sum(1 for d in {p[2] for p in placed} if sum(1 for p in placed if p[2] == d) > PER_DAY)
say(len(placed) == len(sched) and close == 0 and full == 0, f"{close} pairs of meetings clash or sit closer than 30 minutes and {full} days hold more than 5")
say(bool(sched) and conv == len(sched), f"{conv} of {len(sched)} scheduled meetings show UTC times equal to the local times converted with the time zone file")
seen, dup, noinfo = set(), [], []
for r in reqs:
key = tuple(r[c] for c in ("person", "company", "kind", "city", "duration_min", "window_start", "window_end"))
if key in seen: dup.append(r["request_id"])
elif r["duration_min"].strip() == "" or not r["window_start"].strip() or not r["window_end"].strip(): noinfo.append(r["request_id"])
seen.add(key)
musts = [r["request_id"] for r in reqs if r["priority"] == "must" and r["request_id"] not in dup + noinfo]
m_ok = sum(1 for k in musts if status[k] == "scheduled"); d_ok = sum(1 for k in dup if status[k] == "duplicate"); n_ok = sum(1 for k in noinfo if status[k] == "needs_info")
stray = sum(1 for k in byid if (status[k] == "duplicate" and k not in dup) or (status[k] == "needs_info" and k not in noinfo))
say(m_ok == len(musts) and d_ok == len(dup) and n_ok == len(noinfo) and stray == 0,
f"{m_ok} of {len(musts)} must requests are scheduled, {d_ok} of {len(dup)} repeated requests are marked duplicate, {n_ok} of {len(noinfo)} with no length are marked needs_info and {stray} other requests carry those two marks")
printed = set(re.findall(r"(?<![\d:])\d\d:\d\d(?![\d:])", " ".join(p.read_text() for p in sorted((root/"input").glob("*")))))
for i in ids:
f = flights[i]
printed.add((t(f["depart_local"]) - timedelta(minutes=BEFORE)).strftime("%H:%M")); printed.add((t(f["arrive_local"]) + timedelta(minutes=AFTER)).strftime("%H:%M"))
clocks = re.findall(r"(?<![\d:])(\d\d):(\d\d)(?![\d:])", md)
c_ok = sum(1 for h, m in clocks if int(h) < 24 and (m in ("00", "15", "30", "45") or f"{h}:{m}" in printed))
say(len(clocks) >= 2 * n_sched > 0 and c_ok == len(clocks), f"{c_ok} of {len(clocks)} clock times in agenda.md are on the quarter hour, printed in an input file or the edge of the closed time around a chosen flight")
# each meeting sits under a line for its own day, and a day line carries no figure but its day and year
FIG = r"(?<![\w.-])\d(?:[\d,]*\d)?(?:\.\d+)?(?![\w-])"
DAYWORD = r"(?i)\b(mon|tue|wed|thu|fri|sat|sun|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)"
year = int(FIRST_DAY[:4]); under, day_now, day_lines = {}, None, 0
for ln in md.splitlines():
lead = re.search(r"\b[RF]-\d+\b", ln)
if lead:
under.setdefault(lead.group(0), day_now); continue
iso = re.findall(r"\d{4}-\d\d-\d\d", ln); other = [float(x) for x in re.findall(FIG, re.sub(r"\d\d:\d\d", " ", ln)) if float(x) != year]
if len(iso) == 1 and not other: day_now = iso[0]; day_lines += 1
elif not iso and len(other) == 1 and re.search(DAYWORD, ln): day_now = f"{FIRST_DAY[:8]}{int(other[0]):02d}" if other[0] < 32 else "?"; day_lines += 1
elif re.search(DAYWORD, ln) and (iso or other) and ln.lstrip().startswith("#") and day_now: day_now = "?"
placed_right = sum(1 for k in sched if under.get(k) and (got[k].get("local_start") or "").strip()[:10] == under[k])
say(bool(sched) and placed_right == len(sched), f"{placed_right} of {len(sched)} meetings in agenda.md sit under the line for their own day")
declined = [k for k in byid if status[k] == "declined" and k not in dup + noinfo]
could = []
for k in declined:
r = byid[k]; ws = utc(t(r["window_start"]), r["city"], tz); we = utc(t(r["window_end"]), r["city"], tz); s = ws
while ids and s + timedelta(minutes=int(r["duration_min"])) <= we:
e = s + timedelta(minutes=int(r["duration_min"])); c = where(s, ids, flights, tz)
if slot_problem(r, s, ids, flights, tz) is None and not clash(placed, s, e, local(s, c, tz).date()): could.append(k); break
s += timedelta(minutes=15)
say(bool(ids) and good == len(sched) and not could, f"{len(could)} of {len(declined)} declined requests could still be added to the agenda without breaking a limit")
sys.exit(0 if ok else 1)
if __name__ == "__main__":
main()
flights.csv: sample data written by Atris. Fingerprint b4f750d72c75.
meeting_requests.csv: sample data written by Atris. Fingerprint 3f39dae16155.
requests_note.md: sample data written by Atris. Fingerprint 0a30b7c495da.
time_zones.csv: sample data written by Atris. Fingerprint 47ab383a039d.
travel_limits.md: sample data written by Atris. Fingerprint eebe7c58fcc0.
agenda.csv: written by the agent. Fingerprint e13a2a7c8d05.
agenda.md: written by the agent. Fingerprint f809c784cf87.
trip_plan.csv: written by the agent. Fingerprint f459d11824d2.