Fix PostgreSQL-tier boolean columns breaking all conversations endpoints #185

Merged
weichen merged 9 commits from fix/pg-boolean-columns into main 2026-10-05 05:07:16 +00:00
Owner

Why

runtime/dev 2026-10-04 14:02 切换 PostgreSQL 档后,前端 GET/POST /api/conversations*、GET /api/events 全部 500,发送消息失败。根因:迁移把 conversations.{pinned,archived,allow_cross_read,cross_private}、users.{must_change_password,is_admin} 在 PG 档建为 BOOLEAN(SQLite 档 INTEGER),store 层用 0/1 字面量比较、int 扫描、boolInt() 写入,pgx 下报 operator does not exist: boolean = integer(42883)、bool 编码错误、column ... boolean but expression integer(42804)。

改动

  • backend gitlink → fix/pg-boolean-columns(685bd0d):projects.go / auth.go 共 9 处改为跨方言 bool 参数与 bool 扫描;两档均 INTEGER 的列(hitl_cards.resolved、profiles.builtin、activity_cards.pinned)不动。

Evidence

  • 红(main 4fd03ee + AGENT_PG_TEST_DSN 指向临时库):TestConversationFlagsAndTaskList / TestAdminAccountsAndSessions FAIL,错误与线上同类;线上 GET /api/conversations 返回 42883。
  • 绿(本分支):backend ./internal/store/ 全量 PG 档 ok、./internal/pgbus/ ok、make test-backend SQLite 档全绿;Dev 仓 make test 组合验证通过(2026-10-04)。
  • task-sync:sync_base=4fd03eee62(main 未前进)。
  • 已知先存(非本次范围):runmgr PG 集成测试的 gin_trgm_ops 42704。

Impact

conversations 列表/详情/标记与用户认证态读写两档一致;SQLite 行为不变。

合入顺序

先合 Backend PR #62;若产生 merge commit,需把本分支 gitlink 重钉到 Backend main 新头并 task-sync 后再合入本 PR。

Refs: 任务卡 .task/fix-pg-boolean-columns.md(同文档)

## Why runtime/dev 2026-10-04 14:02 切换 PostgreSQL 档后,前端 `GET/POST /api/conversations*`、`GET /api/events` 全部 500,发送消息失败。根因:迁移把 `conversations.{pinned,archived,allow_cross_read,cross_private}`、`users.{must_change_password,is_admin}` 在 PG 档建为 BOOLEAN(SQLite 档 INTEGER),store 层用 0/1 字面量比较、int 扫描、boolInt() 写入,pgx 下报 `operator does not exist: boolean = integer`(42883)、bool 编码错误、`column ... boolean but expression integer`(42804)。 ## 改动 - backend gitlink → fix/pg-boolean-columns(685bd0d):projects.go / auth.go 共 9 处改为跨方言 bool 参数与 bool 扫描;两档均 INTEGER 的列(hitl_cards.resolved、profiles.builtin、activity_cards.pinned)不动。 ## Evidence - 红(main 4fd03ee + AGENT_PG_TEST_DSN 指向临时库):TestConversationFlagsAndTaskList / TestAdminAccountsAndSessions FAIL,错误与线上同类;线上 GET /api/conversations 返回 42883。 - 绿(本分支):backend `./internal/store/` 全量 PG 档 ok、`./internal/pgbus/` ok、`make test-backend` SQLite 档全绿;Dev 仓 `make test` 组合验证通过(2026-10-04)。 - task-sync:sync_base=4fd03eee62(main 未前进)。 - 已知先存(非本次范围):runmgr PG 集成测试的 gin_trgm_ops 42704。 ## Impact conversations 列表/详情/标记与用户认证态读写两档一致;SQLite 行为不变。 ## 合入顺序 先合 Backend PR #62;若产生 merge commit,需把本分支 gitlink 重钉到 Backend main 新头并 task-sync 后再合入本 PR。 Refs: 任务卡 .task/fix-pg-boolean-columns.md(同文档)
weichen added 4 commits 2026-10-04 14:53:25 +00:00
Why:
The dev runtime switched to the PostgreSQL tier today and every
conversation endpoint started returning 500. Migrations define
conversations.pinned/archived/allow_cross_read/cross_private and
users.must_change_password/is_admin as BOOLEAN on PostgreSQL but
INTEGER on SQLite, while the store layer compared them with 0/1
literals, scanned them into int, and wrote them via boolInt().
Under pgx these fail with 42883 (operator does not exist: boolean =
integer), bool encode errors, or 42804 (column is of type boolean but
expression is of type integer).

Evidence:
- main 4fd03ee with AGENT_PG_TEST_DSN: TestConversationFlagsAndTaskList
  and TestAdminAccountsAndSessions fail with the errors above; live
  GET /api/conversations returned "operator does not exist: boolean =
  integer (SQLSTATE 42883)".
- this branch: full ./internal/store suite green on the PostgreSQL tier
  (AGENT_PG_TEST_DSN against a scratch database), pgbus green,
  make test-backend green on the SQLite tier.
- scan into *bool and Go bool parameters are cross-dialect: pgx encodes
  bool natively; database/sql converts bool<->0/1 for SQLite.
- pre-existing and out of scope: ./internal/runmgr PG integration tests
  fail on main too (gin_trgm_ops invisible inside the search_path
  isolation schema, 42704).

Impact:
Conversations list/detail/flags and user auth-state reads/writes now
work identically on both storage tiers; SQLite behavior is unchanged
(same tests green). Boolean columns that are INTEGER in both dialects
(hitl_cards.resolved, profiles.builtin, activity_cards.pinned) keep
boolInt().

Refs: task card .task/fix-pg-boolean-columns.md
Why: advance the backend gitlink to the boolean-column fix so the dev
runtime's PostgreSQL tier stops failing every conversations endpoint.

Evidence: backend branch pushed (685bd0d); make test run recorded in
the task card.

Impact: gitlink-only change in Dev; combined verification via make test.

Refs: .task/fix-pg-boolean-columns.md
Record the sync checkpoint
ci / test (pull_request) Successful in 2m3s
8c0efa2459
weichen added 1 commit 2026-10-04 14:59:04 +00:00
Why: close the evidence loop for review.
Evidence: live endpoints returned 200 after redeploy; probe artifacts cleaned up.
Impact: task-card only.
weichen added 4 commits 2026-10-05 05:07:01 +00:00
Why: Backend PR #62 merged as 3f438b9 (superseded by #64/#65); task card
requires re-pinning the gitlink to the backend merge commit before the
Dev PR can merge.
Evidence: backend go vet + go test ./... -count=1 all ok (29 packages);
merged tree content-identical to backend main.
Impact: modules/backend 685bd0d -> 3f438b9.
Refs: .task/fix-pg-boolean-columns.md
Why: Backend PR #62 dependency is now merged and the Dev branch is
synced with main; the card needs the closing evidence trail.
Evidence: backend 29 packages ok; make test all green at 8a91cded.
Impact: task card only.
Refs: PR #185
weichen merged commit 0ed939115b into main 2026-10-05 05:07:16 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Dev#185