diff --git a/.task/fix-pg-boolean-columns.md b/.task/fix-pg-boolean-columns.md new file mode 100644 index 00000000..efcacb00 --- /dev/null +++ b/.task/fix-pg-boolean-columns.md @@ -0,0 +1,39 @@ +# 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)。 diff --git a/modules/backend b/modules/backend index 8d82408b..3f438b9e 160000 --- a/modules/backend +++ b/modules/backend @@ -1 +1 @@ -Subproject commit 8d82408bb72c1cd3beab2051b83290ed735e6ae8 +Subproject commit 3f438b9e8092fbdaefffa6b631aa3d4039550871