fix: daily summary scheduler, persona pull mtime, and stdio shutdown#7
fix: daily summary scheduler, persona pull mtime, and stdio shutdown#7evanclan wants to merge 1 commit into
Conversation
Target the previous UTC day when the 5pm PDT scheduler fires and skip re-send when the archive sidecar already exists. PersonaBackend.pull_all preserves offline-local files that are newer than cloud. Cancel tracked background poll tasks when the MCP stdio session disconnects.
|
@evanclan please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
brandwe
left a comment
There was a problem hiding this comment.
Thanks for this. The persona mtime and background-task shutdown pieces look directionally good, and the targeted tests are passing locally.
One blocker on the daily summary duplicate gate: summary_already_sent(day) checks for summaries/{day}.json, but _run_daily_summary_internal() writes that sidecar during archive_summary(...) before the email send succeeds. That means a transient Graph send failure, or an operator running run_daily_summary(send=false) as a preview, can create the sidecar and cause the scheduler to skip the actual daily summary email forever.
Suggested fix: use a dedicated sent marker that is written only after send_summary_email completes successfully, e.g. summaries/{day}.sent.json, or check the interaction log for a daily_summary_sent event for that day. Keep the existing HTML/count archive as the render/archive artifact, but do not treat it as proof that mail was delivered.
Regression tests I’d expect:
run_daily_summary(send=false)archives/sidecars but does not make the scheduler consider the day sent.- if
send_summary_emailraises after archive, no sent marker is written and the next scheduler pass retries. - after successful send, the sent marker/log gate suppresses duplicate scheduler sends.
Summary
scheduled_summary_day()targets the previous UTC day when the 5pm PDT job fires (fixes empty summaries after UTC midnight).summary_already_sent()skips duplicate sends when the archive sidecar already exists.PersonaBackend.pull_all()compares local file mtime against cloudkey_mtime()and skips overwrite when local is newer (skipped_local_newercounter onPersonaReport)._shutdown_background_tasks()when the stdio session disconnects, so orphaned processes exit cleanly.Closes three P1 items tracked in
TODOS.md.Test plan
pytest tests/tools/test_daily_summary.py tests/storage/test_persona.py tests/test_background_shutdown.py -v(37 passed)ruff checkon touched filesMade with Cursor