import csv, re, datetime def m(t): h, mi = t.split(':') return int(h) * 60 + int(mi) def f(x): return f"{x // 60:02d}:{x % 60:02d}" avail = {} for r in csv.DictReader(open('inputs/availability.csv')): avail.setdefault(r['person'], []).append((m(r['available_start']), m(r['available_end']))) rooms = {} for r in csv.DictReader(open('inputs/rooms.csv')): rooms.setdefault(r['room'], []).append((m(r['available_start']), m(r['available_end']))) print('avail', avail) print('rooms', rooms) DAY0, DAY1, L0, L1 = m('09:00'), m('17:00'), m('12:00'), m('13:00') def win(wins, s, e): for a, b in wins: if a <= s and e <= b: return (a, b) return None def ok_day(s, e): return DAY0 <= s and e <= DAY1 and not (s < L1 and e > L0) def check(room, S): E = S + 45 reasons = [] for p in ('Maya', 'Theo', 'Jules'): if not win(avail[p], S, E): reasons.append(f'{p} not available for review {f(S)}-{f(E)}') if not win(avail['Theo'], S - 30, S): reasons.append(f'Theo prep {f(S-30)}-{f(S)} outside his window') if not win(rooms[room], S - 10, E): reasons.append(f'Room {room} not free for setup+review {f(S-10)}-{f(E)}') # follow-up: earliest start F >= E inside the same window as the review, for Maya and Jules wm, wj = win(avail['Maya'], S, E), win(avail['Jules'], S, E) fu = None if wm and wj: for F in range(E, DAY1): if wm[0] <= F and F + 15 <= wm[1] and wj[0] <= F and F + 15 <= wj[1] and ok_day(F, F + 15): fu = F break if fu is None: reasons.append(f'no 15-min follow-up after {f(E)} inside Maya {f(wm[0])}-{f(wm[1])} and Jules {f(wj[0])}-{f(wj[1])}') for s, e, n in ((S - 30, S, 'prep'), (S - 10, S, 'setup'), (S, E, 'review')): if not ok_day(s, e): reasons.append(f'{n} violates work hours/lunch') return reasons, fu feasible = [] for room in sorted(rooms): for S in range(DAY0, DAY1): r, fu = check(room, S) if not r: feasible.append((S, room, fu)) feasible.sort() print('\nFeasible review starts (1-minute grid):') for room in sorted(rooms): ss = [S for S, rm, _ in feasible if rm == room] print(' Room', room, (f(min(ss)) + ' to ' + f(max(ss)), len(ss), 'starts') if ss else 'none') print('Earliest:', f(feasible[0][0]), 'Room', feasible[0][1], 'follow-up', f(feasible[0][2])) print('\nRejected candidates:') for room, t in (('B', '10:00'), ('B', '10:10'), ('C', '09:45'), ('C', '10:00'), ('C', '13:55'), ('B', '14:00'), ('B', '14:10')): r, fu = check(room, m(t)) print(f' Room {room} {t}:', r if r else f'FEASIBLE (follow-up {f(fu)})') # verify deliverable print('\nschedule.csv check:') S, room, fu = feasible[0] expected = { 'Theo prep': (S - 30, S), 'Room setup': (S - 10, S), 'Main launch review': (S, S + 45), 'Decision follow-up': (fu, fu + 15), } rows = list(csv.DictReader(open('output/schedule.csv'))) allok = True for r in rows: s, e = m(r['start_pacific']), m(r['end_pacific']) exp = expected[r['block']] d = datetime.date.fromisoformat(r['date']) def utc(t): dt = datetime.datetime.combine(d, datetime.time(t // 60, t % 60)) + datetime.timedelta(hours=7) return dt.strftime('%Y-%m-%dT%H:%MZ') ok = ((s, e) == exp and r['start_utc'] == utc(s) and r['end_utc'] == utc(e) and int(r['duration_min']) == e - s and d.strftime('%A') == 'Tuesday') allok &= ok print(' ', r['block'], r['start_pacific'], r['end_pacific'], r['start_utc'], r['end_utc'], 'OK' if ok else 'MISMATCH') print(' rows:', len(rows), 'columns consistent:', all(None not in r and None not in r.values() for r in rows)) print(' main review room field:', [r['location'] for r in rows if r['block'] == 'Main launch review'], 'expected Room', room) print(' ALL OK' if allok and len(rows) == 4 else ' PROBLEM') txt = open('output/risk-note.md').read() print('\nrisk-note.md words (whitespace split):', len(txt.split())) print('risk-note.md words (alnum tokens):', len(re.findall(r"[A-Za-z0-9][A-Za-z0-9:\-–'.]*", txt))) inv = open('output/invitation-draft.txt').read() for k in ('Maya', 'Theo', 'Jules', 'Nora', 'Optional', 'Room C', 'Agenda', 'NOT SENT', '21:00-21:45 UTC'): print(' invitation contains', repr(k), k in inv)