test: signup-abuse DB tests read the last psql line; business schema lists the two new tables (BUG-2402 follow-up)
Independent Staging Quality Gate / validate-python (push) Successful in 8m32s
Independent Staging Quality Gate / validate-frontend (push) Failing after 4m42s
Independent Staging Quality Gate / publish (push) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
This commit is contained in:
2026-11-26 00:57:35 +08:00
co-authored by Claude Opus 5.5
parent a8129e55c6
commit 3b47f8afa9
3 changed files with 17 additions and 4 deletions
+2
View File
@@ -32663,3 +32663,5 @@
- 防复发:上述测试;`deploy/README.md`「注册防薅」一节写明环境变量和开通 Turnstile 的步骤。
- 关联记录:BUG-1355(聊天按用户限流)、BUG-2395(验证码邮箱后缀检查)、BUG-2348(花费告警兜底)。
- 修复版本:分支 `claude/signup-abuse-2402`。
- **BUG-2402 跟进(2026-11-26)**:staging 门禁 8731 两条数据库测试失败:① `database-local-business` 的 public 表清单没加新表 `first_consult_free_claims`、`request_rate_counters`;② `database-signup-abuse-2402` 用 `set role …; select …` 时 psql 第一行输出 `SET`,断言拿到 `SET\ngranted`。修复:清单按原值/新值/原因补上两张表;测试取输出最后一行。本机没有 docker,这两条只能在 CI 跑。
@@ -416,6 +416,10 @@ test("local PostgreSQL applies the reviewed business schema and serves authentic
"feature_flags",
// This migration intentionally adds the server-owned feature pricing table.
"feature_pricing",
// 原值: feature_pricing 之后直接是 model_config_versions
// 新值: 加入 first_consult_free_claims
// 原因: BUG-2402 注册防薅,免费第一问按设备/网络摘要登记
"first_consult_free_claims",
"model_config_versions",
"model_configs",
"model_connection_test_evidence",
@@ -454,6 +458,10 @@ test("local PostgreSQL applies the reviewed business schema and serves authentic
// 原因: 「更新说明」(issue #331,20261122130000_release_notes.sql)
"release_note_reads",
"release_notes",
// 原值: release_notes 之后直接是 reply_quality_snapshots
// 新值: 加入 request_rate_counters
// 原因: BUG-2402 聊天限额计数存数据库,重启不清零
"request_rate_counters",
"reply_quality_snapshots",
"reply_ratings",
// 原值: reply_ratings 之后直接是 synastry_reports
@@ -15,6 +15,9 @@ const IDENTITY = ["identity_runtime", "identity-runtime-test-password"] as const
const users = Array.from({ length: 7 }, (_, index) => `78000000-0000-4000-8000-00000000000${index + 1}`);
const digest = (char: string) => char.repeat(64);
// 原值:直接 .trim() 取 psql 输出 新值:取最后一行 原因:「set role …; select …」的输出第一行是 SET(CI run 8731)
const lastLine = (out: string): string => out.trim().split("\n").pop()!.trim();
test("free-question screening, durable counters and the login-code table", () => {
const fixture = startPostgresFixture();
try {
@@ -29,8 +32,8 @@ test("free-question screening, durable counters and the login-code table", () =>
users.map((id, index) => `('${id}','u${index}@example.com',0)`).join(",")} on conflict (id) do nothing`);
const screen = (user: string, device: string | null, address: string | null, disposable = false) =>
fixture.psqlAs(...SERVICE, `set role service_role; select public.screen_first_consult_free('${user}'::uuid, ${
device ? `'${device}'` : "null"}, ${address ? `'${address}'` : "null"}, ${disposable}, 3);`).trim();
lastLine(fixture.psqlAs(...SERVICE, `set role service_role; select public.screen_first_consult_free('${user}'::uuid, ${
device ? `'${device}'` : "null"}, ${address ? `'${address}'` : "null"}, ${disposable}, 3);`));
// Device: the first account on a device gets it, the second does not.
assert.equal(screen(users[0]!, digest("a"), digest("1")), "granted");
@@ -59,8 +62,8 @@ test("free-question screening, durable counters and the login-code table", () =>
assert.throws(() => fixture.psqlAs("app_runtime", "app-runtime-test-password", "select count(*) from public.first_consult_free_claims"));
// Durable counters: 2 per minute → the third is refused and nothing is written for it.
const consume = () => fixture.psqlAs(...SERVICE,
"set role service_role; select public.consume_request_rate_limits(array['consultMinute:x','consultHour:x'], array[60,3600], array[2,120]);").trim();
const consume = () => lastLine(fixture.psqlAs(...SERVICE,
"set role service_role; select public.consume_request_rate_limits(array['consultMinute:x','consultHour:x'], array[60,3600], array[2,120]);"));
assert.equal(consume(), "0");
assert.equal(consume(), "0");
assert.ok(Number(consume()) >= 1);