From 36df8c70fb22060793edbc23c850275aa9ae74b3 Mon Sep 17 00:00:00 2001 From: 134 Date: Wed, 21 Oct 2026 12:05:13 +0800 Subject: [PATCH] chore(deploy): include UTC-safe checks for active canvas tasks --- scripts/zcode-agent/active-run-deploy-check.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 scripts/zcode-agent/active-run-deploy-check.sql diff --git a/scripts/zcode-agent/active-run-deploy-check.sql b/scripts/zcode-agent/active-run-deploy-check.sql new file mode 100644 index 000000000..851986a8e --- /dev/null +++ b/scripts/zcode-agent/active-run-deploy-check.sql @@ -0,0 +1,11 @@ +-- Application timestamps are UTC stored without time zone. Compare them to an +-- explicit UTC clock; an implicit cast uses the database session's time zone +-- and can incorrectly report active tasks as eight hours old. +SELECT json_build_object( + 'images', (SELECT count(*) FROM "CanvasImageTask" + WHERE status IN ('pending', 'running') + AND "updatedAt" > timezone('UTC', clock_timestamp()) - interval '90 minutes'), + 'agents', (SELECT count(*) FROM "CanvasAgentRun" + WHERE status = 'running' + AND "updatedAt" > timezone('UTC', clock_timestamp()) - interval '2 minutes') +);