Skip to content

fix(dev): avoid CI run response buffer overflow - #4469

Merged
Grapedge merged 1 commit into
mainfrom
fix/dev-release-ci-buffer
Oct 28, 2026
Merged

Grapedge merged 1 commit into
mainfrom
fix/dev-release-ci-buffer

Conversation

@kimi-agent-bot

@kimi-agent-bot kimi-agent-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

修复 Dev Release 在 main CI 已成功时仍因本地缓冲区溢出而在 prepare 阶段失败的问题。

关联失败 run:https://github.com/MoonshotAI/kimi-code/actions/runs/40490765668

Bug Reproduction Steps

  1. 在 main 提交已有成功 CI 的情况下,手动触发 Dev Release。
  2. prepare / Check latest main commit 读取最近 100 条成功 CI run。
  3. 完整响应超过 Node execFileSync 默认 1 MB stdout buffer,任务以 spawnSync gh ENOBUFS 失败;未生成版本,也未创建 Release 或修改 CDN。

本地使用同一 node scripts/dev-release.mjs select 调用可稳定复现。

Root Cause

select() 只需要成功 run 的 head_sha,却把 100 条完整 workflow-run JSON 读进 Node 默认 1 MB buffer。本次是根本修复:保持查询与门禁语义不变,在 gh 进程内完成字段投影,只把必要 SHA 行传给 Node,而不是单纯扩大缓冲区。

Code Changes

 select
-  gh api ... > 解析 100 条完整 run JSON > 逐项取 head_sha
+  gh api ... --jq '.workflow_runs[].head_sha' > 读取必要 SHA 行
  • 新增 listSuccessfulMainCiShas(),封装不变的 main / push / success / 100 条查询。
  • select() 继续用原来的 selectDevCommit() 判定目标 SHA 是否通过 CI。
  • 新增回归测试,固定 --jq 投影与查询条件,防止退回大响应。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
Dev Release 的 CI 查询传输内容 100 条完整 run JSON 进入 Node buffer 相同查询只返回 head_sha 行 Dev Release prepare;终端用户不直接使用此路径 无需;查询条件和通过判定不变

CLI 参数、配置、客户端契约、版本计算、main-only / CI 成功门禁均无用户可感知变化。

覆盖:

  • scripts/dev-release.test.mjs:新增查询投影回归测试。
  • node --test scripts/release-trigger.test.mjs scripts/dev-release.test.mjs:14/14 通过。
  • 修复后真实 select:输出 skip=false 与目标 main SHA。
  • git diff --check:通过。

本 PR 仅改 CI/release 自动化,不需要 changeset 或用户文档更新。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related failed run above(仓内 CI 修复,无外部 issue).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete;没有 removed behavior、flipped default 或终端用户可见变化.
  • Ran gen-changesets skill;本 PR 为 CI-only,无需 changeset.
  • 本 PR 不改变用户行为,无需 doc update.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T11:23:43.688472Z 8b4c5ae Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@changeset-bot

changeset-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8b4c5ae

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@8b4c5ae
npx https://pkg.pr.new/@moonshot-ai/kimi-code@8b4c5ae

commit: 8b4c5ae

@kimi-agent-bot

Copy link
Copy Markdown
Collaborator Author

@codex review
评审约定:

  1. 只审本 PR 相对 base 的 diff;base 存量问题请单列为 note,不作阻塞意见。
  2. 同类问题请一次性列出 diff 内全部位置,不逐轮分批提出。
  3. 纯风格/个人偏好意见不发;每条意见标注严重度(P0 阻断 / P1 应修 / P2 建议)。

ticket: 836652

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8b4c5ae093

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Grapedge
Grapedge merged commit b9fa2b1 into main Oct 28, 2026
18 checks passed
@Grapedge
Grapedge deleted the fix/dev-release-ci-buffer branch October 28, 2026 05:16
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 5, 2026
Port of upstream MoonshotAI/kimi-code 9793044 (MoonshotAI#4425) with the rest of
the chain it opened: b9fa2b1 (MoonshotAI#4469), 84a392e (MoonshotAI#4490),
ebe14e1 (MoonshotAI#4504) and f695b1f (MoonshotAI#4512). They land together because each
one rewrites files the previous introduced, and the dev->canary rename in
the middle would otherwise create and delete the same script twice.

A release channel is now part of every update decision. `stable` keeps the
existing CDN /latest + /latest.json feed; `canary` reads the
/channels/canary.json pointer and never falls back to stable, because the two
are different release lines. The rename from `dev` to `canary` (MoonshotAI#4490) is
part of this landing, so the channel name, the CDN pointer and the canary
release script's `-canary.` version suffix all agree. The channel comes from the installed version's prerelease
tag, KIMI_CODE_UPDATE_CHANNEL, or the homebrew install source (always
stable); an unusable value warns and keeps the installed channel. A pointer
for another channel is a switch, not an upgrade, and only the interactive
prompt can act on it.

The update cache and the staged native record both carry the channel, so a
stage downloaded for one line is never adopted by the other, and the hidden
downloader takes --channel / --switch-channel alongside --manual. Rollout
gating stays off for a switch. The canary release script derives its base
version from `changeset status` and refuses a run that would replace a
newer published canary.

CI gains a scripts-tests job: the root test run covers the workspace
packages only, so scripts/test (release trigger, canary release) had no job
running it anywhere.

Local-form notes:
- The fork's update tree was restructured by 8c865f4 (MoonshotAI#2994 staged
  swap): preflight injects spawn/clock through PreflightDeps, the install
  lock and auto-install gates live in install-lock.ts / auto-install.ts,
  and main() moved to cli/main.ts. The ported code keeps that shape
  instead of upstream's parameter lists.
- All new copy goes through t() with en/zh keys (14 new keys) rather than
  upstream's literals, because check:no-hardcoded-prose is a baseline gate
  here. Regenerating that baseline after the change lowers sub/upgrade.ts
  from 8 to 7 literals (the install failure message is localized now) and
  rewrites the digests of update/cdn.ts and update/native-swap.ts for
  reworded diagnostics.
- The CDN URL helpers live in constant/region-urls.ts here, not
  constant/app.ts, so kimiCodeCdnDevChannelUrl is added there.
- The fork prompts from the cache and revalidates after the user accepts,
  so the tests pin the prompt at the cached plan and the install at the
  refreshed one; upstream refreshes before prompting.
- ci.yml gets a bun scripts-tests job instead of upstream's node
  release-workflow-tests, and the canary workflow uses bun plus
  `bun pm pkg set` / `bun publish` in place of pnpm and node. The canary
  publish keeps upstream's repository_owner guard, so this fork's CI never
  publishes; per AGENTS.md the release/publish commands themselves are
  still not run from this repository.
- native-stage's two new guards are localized too, since the baseline is
  shrink-only and may not absorb new literals.

Verified: apps/kimi-code typecheck clean apart from two untouched TUI test
files (footer/welcome) that are already red at HEAD; test/cli/update 14
files 215 pass, update-download 20, upgrade 17, native-stage 34/1 skip,
scripts suite 228; oxlint --type-aware 0 errors on the touched files;
check:no-comments, check:no-hardcoded-prose, check:locale-keys,
check:locale-placeholders, check:t-coverage and check:status-surface-i18n
green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants