Commit Graph
5 Commits
Author SHA1 Message Date
Rohit Prasad 47f26dd90c Merge pull request #50 from asklokesh/fix/automation-schedule-dst-and-weekday
Fix automation scheduling: DST-correct 'local' times and off-by-one weekday labels
2026-08-23 21:45:04 -07:00
Rocky DeStefano 0d9df38ae9 test: fix flaky test_scheduler_runs_due_task_and_advances near minute boundaries
The test forces an every-minute cron task due and sleeps a fixed 0.2s with
tick_seconds=0.05. After the first (catch-up) run the scheduler correctly
advances next_run to the next minute boundary; when the test happens to start
within ~0.2s of a boundary, that boundary falls inside the sleep window and
the task legitimately fires a second time, failing 'assert ran == [t.id]'.
Harness race, not a scheduler bug (the running-guard and post-run advance are
correct). Wait on an event set by the fake runner and stop the scheduler
immediately after the first run - the advance is synchronous once the runner
returns, so no second tick can fire. Verified 15/15 plus an adversarial
shifted-clock repro at the minute boundary.
2026-07-26 12:45:54 -06:00
asklokesh c2adf7320c Fix automation scheduling: DST-correct 'local' times and off-by-one weekday labels
Two schedule bugs, both in the default-local, everyday path.

1. DST: one-time 'local' tasks fired at the wrong wall-clock across a DST
   boundary (coworker/automation/store.py)

   _tz("local") returned datetime.now().astimezone().tzinfo, a FIXED offset
   equal to whatever was in effect at compute time. A "once" task created in
   summer (EDT, -04:00) for a winter date (EST, -05:00) bound the naive
   datetime to -04:00, so 08:00 fired at 07:00 - an hour early - and for a
   one-shot task next_run is computed once at creation and never self-heals.

   Fix: _tz returns None for 'local' (and for an unknown IANA name) instead of
   a frozen offset, and the naive datetime is left naive. datetime.timestamp()
   and croniter over a naive local base apply the correct local DST offset for
   the actual fire date via the C library. Named IANA zones still anchor via
   ZoneInfo. No new dependency.

2. Weekday labels were a day late (coworker/automation/models.py)

   Cron day-of-week is 0/7=Sunday, 1=Monday..6=Saturday, but _DOW started at
   Monday, so `_DOW[int(dow) % 7]` rendered dow 1 (Monday) as "Tuesday" and
   dow 0 (Sunday) as "Monday" on every weekly automation card. Reordered the
   list to start at Sunday to match cron semantics.

Regression tests added; an existing assertion that encoded the off-by-one
("Monday" for cron dow 0) is corrected to "Sunday".
2026-07-23 16:44:21 -04:00
Rohit C Prasad 2451486609 port aisuite#380: slack installer pre-add, mcp oauth quarantine, automation toast, e2e fixes
Slack installer joins the workspace allow-list on managed connect; MCP interactive oauth only from explicit connects.
Run-started toast over a new app-wide /ws/events socket; Automations e2e locators scoped to the account menu.
2026-07-21 12:56:36 -07:00
Rohit C PrasadandDevika 2b45018ffa OpenWorker: initial import
Imported from andrewyng/aisuite@1b4bbf303e
(contents of its platform/ directory, hoisted to the repo root).
Development history prior to this commit lives in that repository.

Co-authored-by: Devika <devikaverma11@gmail.com>
2026-07-21 11:09:41 -07:00