From 79835cf3c19fb0a22caddf359706968f525c3d1b Mon Sep 17 00:00:00 2001 From: host Date: Sun, 1 Nov 2026 18:26:43 +0000 Subject: [PATCH] code-to10 v5: fix November date failure in arch-converge quota gate fixture (fixture day follows current UTC month; assertions and gate semantics unchanged; frozen-semantics header updated explicitly) (cherry picked from commit 073950043ed65039e19be8a4b6d725a44a662879) Reconcile-note: this datefix was missing from the solidify line (aa30d40's test_arch_converge.py had no _current_month_day and still failed in November, while 10023fb/6841f28 contained it); added here as the separately-labeled fix for that replay omission, per the reconcile brief. --- cloud/tests/test_arch_converge.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/cloud/tests/test_arch_converge.py b/cloud/tests/test_arch_converge.py index c4070a0..28777dc 100644 --- a/cloud/tests/test_arch_converge.py +++ b/cloud/tests/test_arch_converge.py @@ -13,6 +13,18 @@ 无配额行按默认值,显式 NULL 行才是不限额。 - 失联清理只在 interrupted + 心跳停滞严格超阈时放行; 容器清理只认 codex-<32 位 hex>,绝不按前缀删。 + +设计变更 2026-11-02(11 月日期失败修复,code-to10 v5): +- 旧声明:本文件固件日期一律写死(_cost_row 默认 + day="2026-10-31"),未区分“按当月查用量”与“按指定月 + 查用量”两类测试。 +- 新声明:按当前 UTC 月查用量的门禁测试,固件日期必须 + 跟随当前 UTC 月(_current_month_day(),当月 1 日); + 按指定月查用量的测试仍用写死日期 + 显式月份查询。 +- 为什么改:门禁(automations._automation_quota_exceeded) + 按当前 UTC 月查用量,写死 2026-10-31 的固件在 + 2026-11-01 起恒败(10 月行计为 0,门禁返回 None); + 失败的是固件不是门禁逻辑;断言与门禁语义一字未改。 """ import inspect @@ -21,6 +33,7 @@ import sqlite3 import sys import tempfile import unittest +from datetime import datetime, timezone from pathlib import Path from unittest import mock @@ -91,6 +104,18 @@ def _cost_row(conn, task_id, usd, inp, out, source, day="2026-10-31"): conn.commit() +def _current_month_day(): + """门禁测试用固件日期:当前 UTC 月的 1 日。 + + 门禁按当前 UTC 月查用量,固件日期必须落在当月;写死 + 某月某日会在月份滚动后恒败(2026-11 实测)。只用于 + 按当月查用量的门禁测试;按指定月查用量的测试(如 + test_monthly_usage_actual_only)仍用写死的 2026-10-31 + 固件 + 显式 "2026-10" 查询,不受影响。 + """ + return datetime.now(timezone.utc).strftime("%Y-%m-01") + + class TimeoutConvergeTestCase(unittest.TestCase): def test_constants_match_old_literals(self): self.assertEqual(timeouts.APPROVAL_DEFAULT_SECONDS, 3600) @@ -265,13 +290,15 @@ class QuotaConvergeTestCase(unittest.TestCase): try: conn.execute("INSERT INTO user_quotas VALUES('u1', 100000000, 0)") conn.commit() - _cost_row(conn, "t1", None, 999900, 99, "estimated") + _cost_row(conn, "t1", None, 999900, 99, "estimated", + day=_current_month_day()) with mock.patch.dict( os.environ, {"CLOUD_QUOTA_UNPRICED_TOKEN_CAP": "1000"}): # 估算行再大也不拦。 self.assertIsNone(_automation_quota_exceeded(conn, "u1")) - _cost_row(conn, "t1", None, 600, 500, "actual") + _cost_row(conn, "t1", None, 600, 500, "actual", + day=_current_month_day()) blocked = _automation_quota_exceeded(conn, "u1") self.assertIsNotNone(blocked) self.assertIn("quota_exceeded", blocked)