From 8c434aaa717bf2ef5aaee960b197b7c43147e46d Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 4 Oct 2026 14:46:19 +0000 Subject: [PATCH 1/8] Record the task card for fix-pg-boolean-columns --- .task/fix-pg-boolean-columns.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .task/fix-pg-boolean-columns.md diff --git a/.task/fix-pg-boolean-columns.md b/.task/fix-pg-boolean-columns.md new file mode 100644 index 00000000..6922dbec --- /dev/null +++ b/.task/fix-pg-boolean-columns.md @@ -0,0 +1,25 @@ +# fix/pg-boolean-columns 任务卡 + +任务主记录:;状态:进行中;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 +- 授权与交付终点:<本次允许的动作与终点;未授权事项写明> + +## 目标与非目标 + +<预期结果、受影响入口/模块/契约;明确不做什么。> + +## 同步记录 + +| 节点 | sync_base_sha | tested_head_sha | checked_at | +|---|---|---|---| +| 启动 | 4fd03eee6230f82464def08f2543adab27aba948 | 4fd03eee6230f82464def08f2543adab27aba948 | 2026-10-04T14:46:19Z | + +## 结果与验证(完成后填写) + +- 结果: +- 验证: +- 影响与剩余项: From dbdb47ed092447387be09752629e8219bf29b0f8 Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 4 Oct 2026 14:51:28 +0000 Subject: [PATCH 2/8] Make boolean column reads and writes work on both storage tiers 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 --- .task/fix-pg-boolean-columns.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.task/fix-pg-boolean-columns.md b/.task/fix-pg-boolean-columns.md index 6922dbec..dd854e2c 100644 --- a/.task/fix-pg-boolean-columns.md +++ b/.task/fix-pg-boolean-columns.md @@ -6,11 +6,14 @@ - 权威仓: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 环境限制(见剩余项)。 ## 同步记录 @@ -20,6 +23,9 @@ ## 结果与验证(完成后填写) -- 结果: -- 验证: -- 影响与剩余项: +- 结果: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; + - 线上复验:svc.sh dev 重建重启后 `GET /api/conversations`、`GET /api/conversations/{id}` 用临时 API key 返回 200(见 PR 描述)。 +- 影响与剩余项:`./internal/runmgr/` PG 档集成测试在 main 与本分支同样失败(migrate v4 `gin_trgm_ops` 不在 search_path 隔离 schema 内,42704)——测试环境前置问题,先于本次缺陷存在,未在本次处理;SQLite 档行为不变(同一批测试 SQLite 档全绿)。 From 891a84f835db3590238073965157f60c97efefcb Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 4 Oct 2026 14:51:55 +0000 Subject: [PATCH 3/8] Pin backend fix/pg-boolean-columns for cross-tier boolean columns 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 --- modules/backend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend b/modules/backend index fd170110..685bd0d1 160000 --- a/modules/backend +++ b/modules/backend @@ -1 +1 @@ -Subproject commit fd17011047e5059e59df5f2f10965c7b6ef34070 +Subproject commit 685bd0d17118ac37b27fcee6154b33dc09a6a533 From 8c0efa2459878cc804e47513ab19c415c912ebd3 Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 4 Oct 2026 14:52:46 +0000 Subject: [PATCH 4/8] Record the sync checkpoint --- .task/fix-pg-boolean-columns.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.task/fix-pg-boolean-columns.md b/.task/fix-pg-boolean-columns.md index dd854e2c..d39d2426 100644 --- a/.task/fix-pg-boolean-columns.md +++ b/.task/fix-pg-boolean-columns.md @@ -29,3 +29,4 @@ - 绿:本分支同命令全量 `./internal/store/ -count=1` → ok(PG 档);`make test-backend`(SQLite 档)→ 全部 ok;`./internal/pgbus/` PG 档 ok; - 线上复验:svc.sh dev 重建重启后 `GET /api/conversations`、`GET /api/conversations/{id}` 用临时 API key 返回 200(见 PR 描述)。 - 影响与剩余项:`./internal/runmgr/` PG 档集成测试在 main 与本分支同样失败(migrate v4 `gin_trgm_ops` 不在 search_path 隔离 schema 内,42704)——测试环境前置问题,先于本次缺陷存在,未在本次处理;SQLite 档行为不变(同一批测试 SQLite 档全绿)。 +| 同步前验收 | 4fd03eee6230f82464def08f2543adab27aba948 | 891a84f835db3590238073965157f60c97efefcb | 2026-10-04T14:52:46Z | From 8864596467cf840ffb2fcd29e7884bf3684fcd1b Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 4 Oct 2026 14:59:02 +0000 Subject: [PATCH 5/8] Record PR links and live re-verification evidence in the task card Why: close the evidence loop for review. Evidence: live endpoints returned 200 after redeploy; probe artifacts cleaned up. Impact: task-card only. --- .task/fix-pg-boolean-columns.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.task/fix-pg-boolean-columns.md b/.task/fix-pg-boolean-columns.md index d39d2426..5c1a9806 100644 --- a/.task/fix-pg-boolean-columns.md +++ b/.task/fix-pg-boolean-columns.md @@ -1,6 +1,6 @@ # fix/pg-boolean-columns 任务卡 -任务主记录:;状态:进行中;owner:weichen +任务主记录: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 ## 基线与授权 @@ -27,6 +27,6 @@ - 验证(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; - - 线上复验:svc.sh dev 重建重启后 `GET /api/conversations`、`GET /api/conversations/{id}` 用临时 API key 返回 200(见 PR 描述)。 + - 线上复验(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 | From 686c41a0462c983cce2a6adc3255c75ee61ed898 Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 5 Oct 2026 05:03:58 +0000 Subject: [PATCH 6/8] Pin backend main after merging fix/pg-boolean-columns 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 --- modules/backend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend b/modules/backend index 685bd0d1..3f438b9e 160000 --- a/modules/backend +++ b/modules/backend @@ -1 +1 @@ -Subproject commit 685bd0d17118ac37b27fcee6154b33dc09a6a533 +Subproject commit 3f438b9e8092fbdaefffa6b631aa3d4039550871 From 9bac35d198ba31721e47109e569f803226d726af Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 5 Oct 2026 05:04:33 +0000 Subject: [PATCH 7/8] Record the sync checkpoint --- .task/fix-pg-boolean-columns.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.task/fix-pg-boolean-columns.md b/.task/fix-pg-boolean-columns.md index 5c1a9806..0573c5a9 100644 --- a/.task/fix-pg-boolean-columns.md +++ b/.task/fix-pg-boolean-columns.md @@ -30,3 +30,4 @@ - 线上复验(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 | From f3940e409b13697b13d3f205c38f75e10cf9960c Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 5 Oct 2026 05:06:59 +0000 Subject: [PATCH 8/8] Record the backend merge and post-sync acceptance on the task card 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 --- .task/fix-pg-boolean-columns.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.task/fix-pg-boolean-columns.md b/.task/fix-pg-boolean-columns.md index 0573c5a9..efcacb00 100644 --- a/.task/fix-pg-boolean-columns.md +++ b/.task/fix-pg-boolean-columns.md @@ -31,3 +31,9 @@ - 影响与剩余项:`./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)。