Repository navigation
chore: Go 升级到 1.27.4、golangci-lint 升级到 2.15.0,lint 改为全量检查并清理失效的测试与 CI 配置 - #1831
Merged
Merged
Conversation
…p dead tests and CI entries
Toolchain
- go.mod, mise.toml and the three Go base images move from 1.26.10 to 1.27.4.
CI reads the version from go.mod.
- golangci-lint moves from 2.10.1 to 2.15.0 (mise.toml, go-ci.yml). 2.10.1 is
built with Go 1.26 and cannot load a Go 1.27 module at all.
Behavior change that comes with Go 1.27
- encoding/json is backed by the v2 implementation, and the Field of an
UnmarshalTypeError is now the full path, with the index of an array element
and the key of a map value. Two places pass that field on:
- request.field_invalid from httpx.Binder: "items.1.count" where it was
"items.count", "meta.k.count" where it was "meta.count".
- the decode error a tool call returns to the model: "ids.2 must be an
integer" where it was "ids must be an integer".
Top-level and nested object fields are unchanged. docs/errors.md describes
the field, and a test for each place pins it; both fail on Go 1.26.10.
What the new linter reports on the existing code (0 findings on 2.10.1, 205 on
2.15.0, 193 of them in test files)
- noctx (166): httptest.NewRequest becomes NewRequestWithContext. A request
that was given a context right after takes that context directly.
- errcheck (19): an error received from a channel and dropped. Tests log it or
assert it; cmd/bridge reaps Xvnc after killing it and says so.
- gosec G602 (7): loops that re-evaluated turns[i].Messages for every element
index a named slice; two test helpers become slices.Equal.
- govet nilness, staticcheck SA4023: a `case !existingReady` that follows
`case existingReady` is the default, and a clipboard reader that only
returns on failure is not checked for a nil error.
- gofumpt (4), predeclared (1), and four findings kept with a stated reason.
Lint job
- golangci-lint ran with only-new-issues, so findings in code a PR did not
touch were never reported; that is how the above accumulated behind a green
check. The job lints the whole module now and no longer needs full history.
Commit hook
- .husky/checks.mjs decided whether it was the entry point by comparing
argv[1] with its own real path. In a checkout reached through a symlink
(macOS /tmp, a linked worktree directory) the two differ, so the hook ran
nothing and exited 0, for an unknown check name too. It compares real paths.
- scripts/hook-checks.test.mjs inherited the caller's MEMOH_* settings, so a
commit that touches .husky/ and uses the documented
MEMOH_CHECK_TIMEOUT_SECONDS override failed three of its own regression
tests. The fixture drops them.
Removed, not replaced
- internal/channel/identities/service_integration_test.go: `//go:build ignore`
since February; no build includes it.
- internal/settings/default_agent_concurrency_postgres_integration_test.go:
has not compiled since felinics#1110 changed botagents.Service.Delete, and no CI
step builds the integration tag for that package.
- internal/audio/adapter/edge/ws_integration_test.go: calls the live Edge TTS
service with no skip condition and writes mp3 files to the temp directory.
- go-ci.yml: the RedisDecision alternative of a -run pattern, which has
matched no test since felinics#1707 renamed it (the new name is still selected).
- eslint.yml: four path filters shadowed by "packages/**" in the same list.
- eslint.config.mjs: an ignore entry for a file felinics#1813 deleted.
- .golangci.yml: `go: "1.25"` (the default reads go.mod) and settings for two
linters that are not enabled.
chen-ran
marked this pull request as ready for review
November 22, 2026 19:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author
Type
Summary
把 Go 从 1.26.10 升到 1.27.4、golangci-lint 从 2.10.1 升到 2.15.0,并处理升级暴露出来的问题。golangci-lint 2.10.1 用 Go 1.26 构建,加载不了 Go 1.27 的模块(直接 panic),所以两者必须一起升。
版本
go.mod、mise.toml、三个 Go 基础镜像(docker/Dockerfile.server、docker/Dockerfile.workspace、devenv/Dockerfile.server):1.26.10 → 1.27.4。CI 的setup-go读go.mod。mise.toml、go-ci.yml:golangci-lint 2.10.1 → 2.15.0。go.sum不变。随 Go 1.27 来的行为变化(需要审查者留意)
Go 1.27 的
encoding/json改由 v2 实现支撑,UnmarshalTypeError.Field变成完整路径:数组元素带下标,map 的值带键。本仓库有两处把这个字段原样传出去:httpx.Binder→request.field_invalid的args.fielditems.count、meta.countitems.1.count、meta.k.countids must be an integerids.2 must be an integer顶层字段和嵌套对象字段不变。新值能指出是哪一个元素错了,所以没有做兼容处理;
docs/errors.md补了说明,两处各加一个测试钉住(在 Go 1.26.10 下失败)。前端只把field填进{field} is invalid.这句文案,没有按字段值分支。逐项核对了 Go 1.27 其余的默认值变化(移除的 GODEBUG 开关、
tracebacklabels、x509sslcertoverrideplatform、html/template的 meta URL 转义),本仓库都没有用到。新版 lint 报出的存量问题
未改动的
main在 2.10.1 下是 0 条,在 2.15.0 下是 205 条,其中 193 条在测试文件里:httptest.NewRequest改为NewRequestWithContext。原本紧接着.WithContext(ctx)的 8 处直接用那个 context。cmd/bridge在 kill Xvnc 后回收进程的那一处保留丢弃并加nolint说明原因。turns[i].Messages再索引,改为先取成局部切片;两个测试辅助函数改用slices.Equal。case existingReady之后的case !existingReady就是default;剪贴板读循环只在失败时返回,调用方不再判断err != nil。nolint(gosec 4 处:G115 两处、G407、G703;staticcheck SA1019 一处,是仍在兼容期的message_id入参)。Lint 任务改为全量检查
go-ci.yml的 lint 任务原先带only-new-issues: true,只报相对合并基点新增的问题,PR 没碰到的代码里的问题永远不会出现。上面 205 条就是这样在绿色检查后面积累起来的。本 PR 去掉这个选项(以及只为它服务的fetch-depth: 0),任务改为检查整个模块。当前全量为 0 条。这是 CI 策略的改变,不是清理。 以后升级 lint 版本时,存量问题会让所有 PR 变红,直到修完。如果不想在这个 PR 里做,可以单独拿掉这一项,其余改动不依赖它。
提交钩子在符号链接路径下静默跳过全部检查
.husky/checks.mjs用process.argv[1] === fileURLToPath(import.meta.url)判断自己是不是入口。argv[1]是调用时写的路径,后者是真实路径;检出目录经过符号链接时两者不相等(macOS 的/tmp→/private/tmp,或链接出来的 worktree 目录),于是钩子什么都不跑并以 0 退出,传一个不存在的检查名也是 0。改为比较两边的真实路径,并补了回归测试(未修复时失败)。顺带修了钩子自己的回归测试:它继承了调用方的
MEMOH_*环境变量,所以一次改动.husky/并按文档带MEMOH_CHECK_TIMEOUT_SECONDS的提交,会让其中 3 个用例失败。在未改动的main上MEMOH_CHECK_TIMEOUT_SECONDS=600 node --test scripts/hook-checks.test.mjs即可复现。删除(不是替换)
internal/channel/identities/service_integration_test.go//go:build ignore,从 2 月起如此,任何构建都不包含它internal/settings/default_agent_concurrency_postgres_integration_test.gobotagents.Service.Delete的签名后就编译不过;没有 CI 步骤为这个包带integration标签构建,所以没人发现internal/audio/adapter/edge/ws_integration_test.gogo-ci.yml里-run的RedisDecision分支TestPostgresRedisDecisionSurvivesGracefulShutdown改名后,它不再匹配任何测试。删除它不改变 CI 实际运行的内容eslint.yml的 4 条路径过滤packages/**覆盖eslint.config.mjs的一条 ignore.golangci.yml的go: "1.25"和两段设置go.mod;gocyclo、funlen没有启用这里有两处删除之外的缺口,本 PR 都没有补,列出来供决定:
./internal/settings加进migrations.yml的集成测试步骤即可。RedisDecision分支失效的后果:fix(agent): 重启后接管等待中的问题,并正确处理过期回答 #1707 改名后的TestPostgresDecisionSurvivesGracefulShutdown和同一提交新增的TestPostgresShutdownClosesDecisionsOfLostRun从 11 月 2 日起没有任何 CI 步骤选中,在不带数据库的go test ./...里只会跳过。两者在 Go 1.27.4 +-race、fencing 任务的环境下实测通过。要让 CI 重新覆盖,需要在那条-run正则里加上DecisionSurvives|ShutdownCloses。没有处理的
integration标签做 lint 还有 19 条存量问题。CI 不带这个标签 lint,本 PR 没有动。internal/agentcredential和internal/chat/attention的 Postgres 集成测试同样没有 CI 步骤运行(共 6 个用例),但它们能编译并通过,没有删。go.mod的 require 分组不整齐(go mod tidy会重排,1.26.10 下也会改一行),不影响依赖版本,没有夹带。Related Issues
无。
Validation
以下均为 Agent 验证。
自动检查(Go 1.27.4)
go build ./...、go vet ./...、go vet -tags=integration ./...通过;GOOS=linux|windows|darwin GOARCH=amd64交叉编译通过。golangci-lint run ./...(2.15.0,全量):0 条;golangci-lint fmt --diff:无差异;golangci-lint config verify通过。go test -race -count=1 ./...:macOS arm64 上 174 个包通过,无数据竞争。golang:1.27.4(linux/arm64)容器里按 CI 的方式重跑:vet、全量 lint 通过;race 测试 173 个包通过,1 个包失败(见下方"未通过")。Session Runtime (PostgreSQL fencing)的全部步骤、Session Runtime (redis)、连接器断开的集成用例:全部通过。migrations.yml:新库上migrate up→down→up(版本 173,非 dirty),随后的集成测试步骤 6 个包通过。docker/Dockerfile.server的server-builder阶段在 linux/arm64 和 linux/amd64 上用新基础镜像构建成功;开发用的工作区镜像按scripts/prepare-dev-workspace-image.sh重新构建成功。未通过 / 未运行
internal/container/docker的TestCreateContainerMapsDockerConflictToAlreadyExists失败。原因是测试进程本身跑在容器里:代码检测到/.dockerenv后去查询"自己这个容器",测试的假 Docker API 不认识这个请求。未改动的main+golang:1.26.10在同样的容器里同样失败;去掉/.dockerenv后在本分支通过。与升级无关,GitHub 的 VM runner 上没有这个标记。本 PR 没有修。linux/amd64上的测试、Desktop 构建没有在本地运行,交给 CI。actionlint在本机跑不起来(它依赖的 shellcheck 没有选定版本),工作流文件只确认了能解析为 YAML。运行环境与真实界面
用
scripts/dev-compose.sh devenv/docker-compose.yml加一个只改项目名、容器名和端口的覆盖文件,起了一套独立的开发栈(项目memoh-go127,Webhttp://127.0.0.1:28082,Server:28080)。确认了:server 和 channel 容器内是go1.27.4 linux/arm64,go version -m显示运行中的memoh-server由 go1.27.4 构建,容器内挂载的源码与本分支逐文件哈希一致。模型用一个本地的 OpenAI 兼容探针端点(流式输出固定回复,可按提示词发起一次工具调用),所以以下验证的是 Memoh 自己的链路,不是真实模型的行为。
在 headless Chrome 里操作真实界面:
/v1/models并导入模型)、创建 Bot(嵌套 containerd 里创建出工作区)。exec:命令在工作区容器里执行,结果go127-exec-ok回到模型和界面。tool_describe,names的第三个元素故意给成对象:模型收到invalid arguments for tool_describe: names.2 must be a string, got object。这是上面表格第二行在运行时的样子。mcpServers.files.args的第三个元素是对象:服务端返回 400request.field_invalid,args.field为mcpServers.files.args.2,对话框显示 "mcpServers.files.args.2 is invalid."。这是表格第一行。四次运行在
context_lifecycles里各有一行completed且带快照(reconcileTerminalContextLifecycle是本 PR 改过switch的地方)。Server 和 Channel 日志里没有 ERROR 或 panic。没有在界面上验证的:剪贴板读循环的改动(需要一个桌面会话断线)、
cmd/bridge里 Xvnc 的回收、Feishu/LINE/微信等渠道。这些只有单元测试覆盖。Screenshots / Recordings
Go 1.27.4 构建下的流式回复
工具调用:
exec的结果回到界面;tool_describe的参数错误带上了数组下标names.2MCP 导入:
request.field_invalid指向mcpServers.files.args.2重新加载后从历史里恢复的会话
Human QA