7baf230066
Accepted profiles were selecting a revoked rectification table and failing the report before the engine ran. Degrade to a null window when that optional read fails. Co-authored-by: Cursor <cursoragent@cursor.com>
3.3 KiB
3.3 KiB
PROGRESS · BUG-526 报告链路不得直读已收权的校正表(2026-09-04)
工作树:/Users/jesse/Downloads/Copse/astrology/.worktrees/report-candidate-range-20260904
分支:codex/report-candidate-range-20260904
基线:任务书写 cce919fe;开工 origin/staging HEAD 为 846b6064(含本任务书)。
任务书:仓库根 TASK-report-candidate-range-read-20260904.md
未恢复 service_role 表级权限,未改表/列/RLS/既有 grant,未改 worker 其余生成管线,未改 .gitea/workflows/**,不提升 main。
| 任务 | 状态 | BUG |
|---|---|---|
| 1 两处读取降级 + 语义修正 | 完成 | BUG-526 |
2 只读 RPC + test:db |
完成(本文件定向套件已绿;全量 test:db 见下方门禁输出) |
BUG-526 |
| 3 部署后真实 personal_full | 待部署 | BUG-526 |
| 4 BUG-526 收口 | 完成(修复版本待 staging SHA) | BUG-526 |
实现要点
- 共享 helper
frontend/src/lib/report-candidate-range.ts:只调read_report_candidate_range。permission denied / 抛错 → warn(仅event+reason错误码)→null;空行 →null且不 warn。非法时钟或start > end也当无窗口。 - worker
generate与POST /api/reports的loadCandidateRange都走 helper,不再from("agentic_rectification_cases")/from("birth_time_rectification_cases")。 - 迁移
20260904010000_read_report_candidate_range.sql:security definer、search_path=''、revokepublic/anon/authenticated、grant execute只给service_role。返回值只有start_time/end_time。 completed枚举: 任务书以为它不在birth_time_rectification_cases状态枚举里。20260720010000_conversational_rectification_schema.sql已纳入confirmed与completed两个终态。RPC 使用这两值;前端不再维护一份.in("status", …)列表。abandoned不取窗。
测试
tests/report-candidate-range.test.ts:permission denied / throw / 空行三态;合法窗;敏感度输入无窗口;源码锁两处调用。tests/personal-report-api.test.ts:loadCandidateRange返回null时 create 仍 201,不是calculation_unavailable。原「只信 confirmed/completed 直读」改为 RPC helper 源码锁。tests/database-report-candidate-range.test.ts:service_role可 execute,anon/authenticated不可;表 SELECT 仍 denied;无行返回空;窗口 JSON 只有两列;legacy confirmed 行优先。
让步
无。未 re-grant 表权限。
门禁解堵
7ee7f825 的 CSS 合同脱节已由 0be51e65 / BUG-532 合入 staging,本单不再改那条测试。
门禁输出
./node_modules/.bin/tsc --noEmit:0npm run lint:0 error / 74 warning(既有,未动)- 定向:
report-candidate-range+personal-report-api+personal-report-worker+ migration 源码锁 75 pass npm run test:db(tsx --test --test-concurrency=1 tests/database-*.test.ts):35 pass, 0 fail(含新 RPC 套件)。第一次全量 34/35,database-admin-identity迁移在套件开头失败,单跑即过,属 Docker 争用。- 非数据库
tsx --test tests/*.test.ts:2626 pass;当时 2 fail 为 CSS 合同(已由0be51e65修)与identity-auth-integration(与并行test:db抢 fixture,单跑已过)。