Files
Agent-System-Dev/.task/archive/fix-pg-boolean-columns.md
T
weichen b548256d2e
ci / test (pull_request) Successful in 1m55s
Close 1 merged task card(s) and archive them
Why: branches merged into main had left their task cards open; backfill status and archive to prevent bookkeeping debt.
Evidence: fix-pg-boolean-columns.md(PR#185) — merges verified via git log --merges against origin/main.
Impact: .task/*.md moved to .task/archive/ with status backfilled; no code or submodule change.
Refs: task.sh close (card-autoclose-r1)
2026-10-05 05:08:50 +00:00

46 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# fix/pg-boolean-columns 任务卡
任务主记录:Dev PR #185 https://git-home.u1680832.nyat.app:30319/weichen/Agent-System-Dev/pulls/185(依赖 Backend PR #62 先合入;若 Backend 产生 merge commit 需重钉 gitlink 后再合);状态:已完成(回填);owner:weichen
## 基线与授权
- 权威仓:ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git;目标分支:main;R0(initial_base_sha)= 4fd03eee6230f82464def08f2543adab27aba948
- 工作区:/home/weichen/projects/Agent-System-Dev-wt-fix-pg-boolean-columns(worktree);分支:fix/pg-boolean-columns
- 授权与交付终点:修复 PG 档 conversations/users boolean 列访问(授权范围 = 本次报障的开发服务回归可用);终点 = PR 建立 + dev 服务重建重启后线上接口复验通过(main 合入由所有者执行)
## 目标与非目标
- 症状:runtime/dev 切换 PostgreSQL 档(2026-10-04 14:02)后,前端 `GET/POST /api/conversations*`、`GET /api/events` 全部 500,发送消息失败。
- 根因:迁移在 PG 档把 `conversations.{pinned,archived,allow_cross_read,cross_private}` 与 `users.{must_change_password,is_admin}` 建为 BOOLEAN(SQLite 档为 INTEGER),store 层沿 SQLite 习惯用 0/1 字面量比较、int 扫描与 boolInt() 写入,pgx 驱动下分别报 `operator does not exist: boolean = integer`(42883)/ 扫描编码失败 / `column ... is of type boolean but expression is of type integer`(42804)。
- 目标:上述列的读写改为跨方言通用的 Go bool 参数与 bool 扫描,两档全绿。
- 非目标:不改迁移与列类型(线上 PG 已按 BOOLEAN 建表且有数据);不动 hitl_cards.resolved / profiles.builtin / activity_cards.pinned(两档均 INTEGER,不受影响);不处理 runmgr PG 集成测试的 gin_trgm_ops 环境限制(见剩余项)。
## 同步记录
| 节点 | sync_base_sha | tested_head_sha | checked_at |
|---|---|---|---|
| 启动 | 4fd03eee6230f82464def08f2543adab27aba948 | 4fd03eee6230f82464def08f2543adab27aba948 | 2026-10-04T14:46:19Z |
## 结果与验证
- 结果:store/projects.go(scanConversation/GetConversation 直接扫 bool;ListTasks `archived=?` 参数化;SetConversationFlags 传 Go bool)与 store/auth.go(CreateAccount/SetUserPassword/ClearMustChangePassword 参数化;GetUserAuthState/ListUsersAdmin 直接扫 bool)共 9 处修正,双方言通用(pgx 原生 bool;SQLite 经默认参数转换器 0/1)。
- 验证(2026-10-04,PG=127.0.0.1:8890 临时库 agent_store_test):
- 红:main(4fd03ee) `AGENT_PG_TEST_DSN=… go test ./internal/store -run 'TestConversationFlagsAndTaskList|TestAdminAccountsAndSessions'` → FAIL(42804 / encode 1 into bool),与线上 500 同类;
- 绿:本分支同命令全量 `./internal/store/ -count=1` → ok(PG 档);`make test-backend`(SQLite 档)→ 全部 ok;`./internal/pgbus/` PG 档 ok;
- 线上复验(2026-10-04 14:55,dev 服务以 dev@8c0efa2 重建重启,沿用 postgres DSN):`GET /api/conversations` 200;新建项目+会话 → `GET /api/conversations/{id}` 200(messages/runs/resumeSeq 正常)→ `PATCH pinned=true` 200 → `GET /api/events` SSE 正常挂流(此前全部 500)。探测用的临时项目/会话/API key(postgres 与 sqlite 档各一把)已删除吊销,临时测试库 agent_store_test 已 drop。
- 影响与剩余项:`./internal/runmgr/` PG 档集成测试在 main 与本分支同样失败(migrate v4 `gin_trgm_ops` 不在 search_path 隔离 schema 内,42704)——测试环境前置问题,先于本次缺陷存在,未在本次处理;SQLite 档行为不变(同一批测试 SQLite 档全绿)。
| 同步前验收 | 4fd03eee6230f82464def08f2543adab27aba948 | 891a84f835db3590238073965157f60c97efefcb | 2026-10-04T14:52:46Z |
| 同步前验收 | 621324e11d3be723dc380aaa7f901984023ca11f | 8a91cded363c35bdb0505234b9441d925f90807f | 2026-10-05T05:04:33Z |
## 收尾记录(2026-10-05)
- Backend PR #62 已合入:merge commit 3f438b9e8092fbdaefffa6b631aa3d4039550871;分支 fix/pg-boolean-columns 先并入 backend main(4b93abb,#64/#65 已覆盖同一批 boolean 修复,合并树与 backend main 零差异),backend `go vet ./...` 通过、`go test ./... -count=1` 29 包全 ok;远端分支已删除。
- Dev gitlink 重钉 686c41a:modules/backend 685bd0d → 3f438b9(backend merge commit);`make task-sync` 无冲突并入 origin/main(8a91cded,modules/backend gitlink 择优 ours=3f438b9,为 theirs 8d82408 的后代)。
- 组合验证:`make test` 全绿(2026-10-05T05:05,pins ok;backend 全部包 ok;frontend/ui 全部测试通过;knip 55<=55;agent-command ok)。
## 闭合记录(card-autoclose 回填)
- 依据:merge 0ed939115b676339b5b9aba8f3add962a15a46ce(PR #185)已包含于 origin/main,分支成果已落盘;本段为合入后回填。
- 合并主题:Merge pull request 'Fix PostgreSQL-tier boolean columns breaking all conversations endpoints' (#185) from fix/pg-boolean-columns into main
- 归档:随闭合移入 .task/archive/;任务执行期的过程证据见原任务记录与 PR。