Skip to content

fix(cli): require exact daemon marker before env scrub - #8811

Merged
yiliang114 merged 2 commits into
QwenLM:mainfrom
yiliang114:codex/fix-exact-daemon-marker-scrub
Aug 10, 2026
Merged

fix(cli): require exact daemon marker before env scrub#8811
yiliang114 merged 2 commits into
QwenLM:mainfrom
yiliang114:codex/fix-exact-daemon-marker-scrub

Conversation

@yiliang114

Copy link
Copy Markdown
Collaborator

What this PR does

This PR requires QWEN_CODE_SERVE to equal the literal value 1 before applying daemon-only loader environment cleanup. It also extends the existing ACP startup regression table so 0 and false are verified as ordinary non-daemon values.

Why it's needed

The channel attribution fallback already accepts only QWEN_CODE_SERVE=1, but the loader environment cleanup still used a truthy check. As a result, a direct ACP launch with QWEN_CODE_SERVE=0 or QWEN_CODE_SERVE=false reported channel=ACP while unexpectedly removing NODE_OPTIONS and NODE_PATH. This aligns both consumers on the same exact marker contract. Normal daemon launches are unchanged because every in-repository daemon producer writes 1 explicitly.

Reviewer Test Plan

How to verify

  • Run cd packages/cli && npx vitest run src/gemini.test.tsx and confirm all startup tests pass, including the 0 and false marker cases.
  • Run cd packages/cli && npx vitest run src/config/acp-channel-fallback.test.ts and confirm attribution still rejects non-1 marker values.
  • Confirm a daemon-stamped ACP launch still removes inherited loader variables, while a direct ACP launch with QWEN_CODE_SERVE=0 or false preserves them.

Evidence (Before & After)

Before: the direct-ACP regression test failed with expected undefined to be '--import file:///other-checkout/register.mjs' when the ambient marker was 0 or false.

After: the complete startup test file passes with explicit coverage for both values.

Tested on

OS Status
🍏 macOS
🪟 Windows ⚠️
🐧 Linux ⚠️

Environment (optional)

Node.js 22, local unit tests and repository build.

Risk & Scope

  • Main risk or tradeoff: none for daemon-managed sessions; their launchers overwrite the marker with 1.
  • Not validated / out of scope: no end-to-end daemon client session was needed because this change only narrows an already tested startup gate.
  • Breaking changes / migration notes: none.

Linked Issues

Follow-up to #8712 and #8663. Related to #8660.

中文说明

这个 PR 做了什么

本 PR 要求 QWEN_CODE_SERVE 必须严格等于字面量 1,才执行 daemon 专属的 loader 环境清理。同时扩展现有 ACP 启动回归测试,确认 0false 都按普通非 daemon 值处理。

为什么需要

channel 归因回退已经只接受 QWEN_CODE_SERVE=1,但 loader 环境清理仍使用 truthy 判断。因此,直接 ACP 启动如果设置了 QWEN_CODE_SERVE=0QWEN_CODE_SERVE=false,会上报 channel=ACP,却意外删除 NODE_OPTIONSNODE_PATH。本次修复让两个 consumer 遵循同一个精确 marker 约定。正常 daemon 启动不受影响,因为仓库内所有 daemon 生产者都会显式写入 1

Reviewer Test Plan

如何验证

  • 运行 cd packages/cli && npx vitest run src/gemini.test.tsx,确认全部启动测试通过,包括 0false marker 用例。
  • 运行 cd packages/cli && npx vitest run src/config/acp-channel-fallback.test.ts,确认归因逻辑仍拒绝非 1 marker。
  • 确认 daemon 标记的 ACP 启动仍会移除继承的 loader 变量,而设置 QWEN_CODE_SERVE=0false 的直接 ACP 启动会保留这些变量。

前后对比证据

修复前:ambient marker 为 0false 时,直接 ACP 回归测试失败,错误为 expected undefined to be '--import file:///other-checkout/register.mjs'

修复后:完整启动测试文件通过,并显式覆盖这两个值。

测试环境

OS 状态
🍏 macOS
🪟 Windows ⚠️
🐧 Linux ⚠️

环境(可选)

Node.js 22,本地单元测试与仓库构建。

风险与范围

  • 主要风险或权衡:daemon 管理的会话没有变化,其 launcher 会将 marker 覆盖为 1
  • 未验证 / 不在范围内:不需要额外运行端到端 daemon client 会话,因为本次改动只收紧了已有测试覆盖的启动判断。
  • 破坏性变更 / 迁移说明:无。

关联 Issue

#8712#8663 的后续修复,与 #8660 相关。

@qwen-code-ci-bot

qwen-code-ci-bot commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

🚫 Qwen Triage was cancelledview run. The run was cancelled before finishing. Check for a newer run before re-running.

🚫 Qwen Triage 已取消 —— 查看运行。运行未完成即被取消。重跑前请先确认是否有更新的运行。

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Suggestions are inline. Not explored to full depth (tool budget reached): This PR fixes a startup-gate mismatch in the Qwen Code CL...: could not run the test file — the worktree has no usable node_modules ( packages/cli/node_modules exists but is empty, no vitest binary, no root install), an…; This PR fixes a startup-gate mismatch in the Qwen Code CL...: live execution of gemini.test.tsx (blocked by missing worktree dependencies).; This PR fixes a startup-gate mismatch in the Qwen Code CL...: could not execute the test (worktree has no node_modules; parent install stale — vitest fails at transform on ajv/dist/2020.js ).I've completed my review of th….

中文说明

已审查。 建议见行内评论。 未探索到全部深度(达到工具调用预算):This PR fixes a startup-gate mismatch in the Qwen Code CL...:could not run the test file — the worktree has no usable node_modules ( packages/cli/node_modules exists but is empty, no vitest binary, no root install), an…;This PR fixes a startup-gate mismatch in the Qwen Code CL...:live execution of gemini.test.tsx (blocked by missing worktree dependencies).;This PR fixes a startup-gate mismatch in the Qwen Code CL...:could not execute the test (worktree has no node_modules; parent install stale — vitest fails at transform on ajv/dist/2020.js ).I've completed my review of th…

— deepseek-v4-flash via Qwen Code /review (v0.21.8)

Comment thread packages/cli/src/gemini.test.tsx Outdated
@yiliang114
yiliang114 requested a review from wenshao August 9, 2026 11:20
@yiliang114

Copy link
Copy Markdown
Collaborator Author

Review closeout for 026c6f3b8f3fe482c171bbfd5067684048314960:

  • Changed: the two keep-path rows now explicitly clear the daemon marker instead of inheriting the runner environment.
  • Verified: the focused table passes 5/5 with ambient QWEN_CODE_SERVE=1; the full startup file passes 76/76, the ACP fallback suite passes 6/6, and ESLint, Prettier, and git diff --check pass.
  • Intentionally not changed: the previous head's Ubuntu failure was a Core Vitest worker onTaskUpdate timeout after 19,622 tests passed; the changed CLI suite itself passed 76/76, so no unrelated Core code was modified. The branch already contained latest main.
  • Pending: exact-head CI and automatic re-review are running.
中文摘要
  • 改动:两个 keep 路径用例现在显式清空 daemon marker,不再继承 runner 环境。
  • 验证:宿主 QWEN_CODE_SERVE=1 时目标表 5/5;完整启动测试 76/76,ACP fallback 6/6,ESLint、Prettier 和 diff check 均通过。
  • 主动不改:上一 head 的 Ubuntu 失败是 Core Vitest worker onTaskUpdate 超时;19,622 个测试通过,改动涉及的 CLI 套件 76/76,因此未修改无关 Core 代码。分支已包含最新 main
  • 待处理:exact-head CI 与自动复审运行中。

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Suggestions are inline. Not reviewed: build-and-test — Test (macos-latest, Node 22.x) / Test (windows-latest, Node 22.x) / Integration Tests (CLI, No Sandbox) were skipped in CI at this commit and the full packages/cli suite did not complete locally (300s timeout); only the targeted gemini.test.tsx rows ran green. Not explored to full depth (tool budget reached): Incremental re-review of PR #8811 (QwenLM/qwen-code): the...: runtime test execution and tsc typecheck of the changed test file (both blocked by the dependency-resolution failure above); PR review comments/thread history….

中文说明

已审查。 建议见行内评论。 未审查:build-and-test — Test (macos-latest, Node 22.x) / Test (windows-latest, Node 22.x) / Integration Tests (CLI, No Sandbox) were skipped in CI at this commit and the full packages/cli suite did not complete locally (300s timeout); only the targeted gemini.test.tsx rows ran green。 未探索到全部深度(达到工具调用预算):Incremental re-review of PR #8811 (QwenLM/qwen-code): the...:runtime test execution and tsc typecheck of the changed test file (both blocked by the dependency-resolution failure above); PR review comments/thread history…

— deepseek-v4-flash via Qwen Code /review (v0.21.8)

Comment thread packages/cli/src/gemini.test.tsx
Comment thread packages/cli/src/gemini.test.tsx
Comment thread packages/cli/src/gemini.tsx
@yiliang114

Copy link
Copy Markdown
Collaborator Author

This pass reviewed the three newly completed suggestions against the exact head and PR scope. No code or PR-body change was needed.

Intentionally not changed: an unreachable test guard cleanup, mutation-only coverage for removing the ACP conjunct, and duplicated producer-site documentation. None demonstrates a current-head behavior defect; the exact marker regression and contract are already pinned by the existing cases and PR description.

Pending: maintainer review. The current exact-head checks are complete.

中文摘要

本轮对照 exact head 和 PR 范围处理了 3 条新 Suggestion,无需修改代码或 PR 描述。未纳入测试死守卫清理、仅用于 mutation 的非 ACP 组合覆盖,以及重复 producer-site 文档;它们都未证明当前 head 存在行为缺陷,现有用例和 PR 描述已钉住精确 marker 回归与约定。当前等待 maintainer review,exact-head checks 已完成。

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. LGTM! ✅

Not explored to full depth (tool budget reached): PR #8811 (QwenLM/qwen-code) requires QWEN_CODE_SERVE to...: full-file run of gemini.test.tsx (all 76 tests) not performed — only the filtered 5-row table was run.; PR #8811 (QwenLM/qwen-code) requires QWEN_CODE_SERVE to...: npm run typecheck / npm run lint not run for the touched files; the type-inference check of the it.each callback parameters was done by analysis, not comp….

中文说明

未发现问题。LGTM!✅

未探索到全部深度(达到工具调用预算):PR #8811 (QwenLM/qwen-code) requires QWEN_CODE_SERVE to...:full-file run of gemini.test.tsx (all 76 tests) not performed — only the filtered 5-row table was run.;PR #8811 (QwenLM/qwen-code) requires QWEN_CODE_SERVE to...:npm run typecheck / npm run lint not run for the touched files; the type-inference check of the it.each callback parameters was done by analysis, not comp…

— qwen3.8-max via Qwen Code /review (v0.21.8)

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Not reviewed: This PR narrows the daemon-marker check from a truthy tes... — pointed at diff lines it never opened: it made tool calls, but none of them read the diff.

中文说明

已审查。 未审查:This PR narrows the daemon-marker check from a truthy tes...——它被指向 diff 的行却从未打开:有工具调用,但没有一次读取 diff。

— glm-5.2 via Qwen Code /review (v0.21.8)

@yiliang114

Copy link
Copy Markdown
Collaborator Author

Local verification: PASS

Verified exact head 026c6f3b8f3fe482c171bbfd5067684048314960 on macOS.

  • CLI package build: PASS
  • Focused startup and ACP channel suites: PASS (82/82)
  • Exact env-scrub regression matrix: PASS (5/5)
    • daemon ACP with QWEN_CODE_SERVE=1 scrubs NODE_OPTIONS and NODE_PATH
    • direct ACP with an empty marker preserves the loader variables
    • ACP with QWEN_CODE_SERVE=0 preserves the loader variables
    • ACP with QWEN_CODE_SERVE=false preserves the loader variables
    • non-ACP startup preserves the loader variables

The contract is consistent at the surrounding boundaries: ACP channel fallback also accepts only the literal 1, and both in-repository daemon producers write QWEN_CODE_SERVE=1.

No UI screenshot is attached because this change affects child-process environment state, not rendered TUI behavior; a terminal screenshot would not prove the fix.

@yiliang114

Copy link
Copy Markdown
Collaborator Author

@qwen-code-review-bot pls review this pr

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

⚠️ Failed to process this request. Please re-mention the bot to retry.

@chiga0 chiga0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Overview (AI Generated)

PR: #8811 fix(cli): require exact daemon marker before env scrub
Type: Bug fix
Change size: +18/-6 across 2 files
HEAD: 026c6f3b8f3fe482c171bbfd5067684048314960

Findings Summary

  • Critical/Major: 0
  • Minor: 0
  • Nit: 0 unique (confirmed existing suggestions from another reviewer)

Key Observations

This is a tightly scoped bugfix: it aligns the ACP loader-env scrub gate in packages/cli/src/gemini.tsx with the exact QWEN_CODE_SERVE=1 contract already used by resolveAcpChannelFallback. The one-line production change is correct, and the regression table in gemini.test.tsx now explicitly covers 0 and false marker values. I independently verified that every in-repository daemon producer sets the marker to '1' explicitly, so normal daemon behavior is unchanged.

Cross-Validation

Finding Other Reviewer My Assessment
Keep rows should explicitly stub QWEN_CODE_SERVE to avoid ambient env dependence wenshao (R1-1) Confirmed — addressed in commit 026c6f3; keep rows now use ''
daemonMarker !== undefined guard is dead code wenshao (R2-1) Confirmed — all table rows pass explicit strings; Nit-level cleanup
non-ACP row should use marker '1' to pin isAcpMode && conjunct wenshao (R2-2) Confirmed observation, but agree with author it is beyond the current defect scope
Gate comment should document exact '1' contract and stamp sites wenshao (R2-3) Confirmed suggestion, but the contract is already documented in acp-channel-fallback.ts
No issues found qwen-code-ci-bot Confirmed — no blocking defects identified independently

Additional Audit Coverage

Areas I independently checked that go beyond existing findings:

  • Daemon producers: verified packages/acp-bridge/src/spawnChannel.ts and packages/cli/src/serve/channel-worker-supervisor.ts both set QWEN_CODE_SERVE = '1' explicitly.
  • Consumer consistency: verified resolveAcpChannelFallback already uses the exact === '1' check, so the two consumers now match.
  • Straggler truthy checks: searched the codebase for other truthy checks of QWEN_CODE_SERVE / QWEN_CODE_SERVE_ENV; none remain outside the now-fixed gate.
  • Project conventions: ESM, strict TypeScript, collocated tests, and no cross-package relative imports are all satisfied.
  • Sibling consistency: the exact-match pattern is already established in acp-channel-fallback.ts.

Final Verdict

APPROVE / Recommend Merge
The change correctly fixes the root cause (truthy vs. exact marker check), includes focused regression tests, and does not introduce new risks. Existing reviewer suggestions are valid Nits/cleanups that the author has already addressed or scoped out; none are blocking.


This review was generated by QoderWork AI

@yiliang114
yiliang114 added this pull request to the merge queue Aug 10, 2026
Merged via the queue into QwenLM:main with commit c1a6b2d Aug 10, 2026
190 of 192 checks passed
@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Released in v0.21.9.

github-merge-queue Bot pushed a commit that referenced this pull request Aug 12, 2026
…ctions (#8857)

* fix(cli): word review gap disclosures so they cannot read as contradictions

A posted review body on #8811 opened "Reviewed. Not reviewed: This PR
narrows the daemon-marker check from a truthy tes..." and readers could
not tell whether the PR had been reviewed at all. The opener certified a
part of the diff while the disclosure named an agent that never opened
it — both true, but the pair read as a self-contradiction, and the
disclosure subject (a launch-prompt fragment truncated mid-word) looked
like a claim about the whole PR.

- When "Not reviewed:" clauses follow, the opener now says "Reviewed,
  with gaps disclosed below." The certifying and zero-certified openers
  keep their exact wording.
- Agent-derived subjects (the truncated prompt line used when an agent
  is tied to no chunk) render quoted — they are names, not sentences.
- That truncation stops at a word boundary instead of mid-word.

Verdicts, caps, dedup and the certification check are untouched: the
internal subject stays the unquoted label and every structural check
keys on it.

* fix(cli): open gap-carrying review bodies as partial, and de-translate one reason

Feedback on the first wording: "Reviewed, with gaps disclosed below."
still starts with the word the "Not reviewed:" clauses take back, and
readers had to reconcile the pair anyway. The opener now says the review
is PARTIAL instead — "Partially reviewed — gaps disclosed below." — so
opener and disclosures read in one direction (Chinese half:
仅完成部分审查,未覆盖部分见下方披露。).

Also replaces the translationese Chinese rendering of the unopened-agent
reason ("它被指向 diff 的行却从未打开") with natural phrasing.

* fix(cli): keep review gap disclosures unambiguous

* fix(review): preserve distinct agent labels

* fix(review): normalize agent label spacing

* fix(review): keep incomplete review openers honest
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.

5 participants