Repository navigation
fix(ai): 隔离服务商发现测试的用户环境 - #2323
Merged
Merged
Conversation
…214-isolate-ai-environment
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.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
AI 配置发现测试虽然替换了文件来源,仍会把运行测试的开发机环境传给真实 Core。只要环境中有 Claude 配置,原本只期望 Codex 的测试就会额外发现 Claude,导致无关修改的验证失败。
改动 / Changes
Discover保留现有签名及生产行为:读取真实主目录和loginenv快照,再交给显式接收这两个输入的discoverProviders。文件定位、解析和凭据解析始终使用传入的同一快照,包括空快照。fileKernel。测试改用临时主目录和真实 Core 的路径发现、配置解析,覆盖无配置、Codex 文件、Claude 文件、Claude 纯环境、双源并存和配置目录覆写六个场景。pending。不在本 PR 范围内 / Out of scope
无产品功能变化;Core 的配置格式、凭据优先级与公共接口保持原有语义。本 PR 不代替 macOS/Windows 原生完整界面验收。
类型专属:fix
复现与根因
cc16002831ac916ec0f6c2ed98ab891de72f315f,为测试进程提供完全虚构的ANTHROPIC_BASE_URL、ANTHROPIC_API_KEY、ANTHROPIC_MODEL,运行scripts/desktop/desktop-go.sh test -count=1 -timeout=60s -run '^TestProviderDiscoveryUsesRealCoreParser$' ./internal/ai,真实失败为providers = 1 codex, 1 claude; want one Codex provider。相同环境下修复后的整个 AI 包通过。fileKernel只覆盖ConfigurationSources,Discover → Environment → loginenv.Environ → ParseConfiguration仍带入本机环境;Claude 可完全由环境配置,不需要配置文件。该测试已存在于 Viva 迁移0faecba49(Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799),在e02e3ceee(fix(desktop): 八组宿主规则改由 Core 计算,AI 代码移到 internal/ai(重新提交 #1888 到 preview) #1889)移至当前 AI 包。检查项
desktop/internal/ai/provider_test.go,失败输出见上。Choose与工作台服务商发现/配置路径查询继续使用签名不变的生产入口。范围检查 / Scope checks
功能矩阵 / Feature matrix
ai-commit-generation.json的配置发现验证动作;没有把原生验收状态改为已验证。插件归属 / Plugin ownership
UI 验证 / UI evidence
N/A:无界面、文案或可见交互变化。
统一日志系统 / Structured logging
N/A:没有新增生产失败路径、日志事件或生命周期;测试失败信息不输出环境内容和凭据。
界面文案 / i18n
N/A:没有新增用户可见文字。现有语言检查和生成物检查均通过。
逻辑归属 / Logic placement
ai.configuration.sources/ai.configuration.parse。性能与内存 / Performance and memory
N/A:没有新增后台进程、缓存、轮询、依赖或性能敏感工作流;生产入口仍只采集一次环境快照。
设置 / Settings
N/A:没有设置项或设置读写行为变化。
插件契约 / Plugin contract
N/A:没有插件协议、宿主方法或 SDK 变化。
发行包与资源 / Bundle and resources
N/A:没有新增运行时资源或构建资源。现有发行目录只读检查通过。
无用代码与重构 / Dead code and refactoring
fileKernel。验证 / Verification
合入最新
origin/main(ac0305fe78cc11d88c33e3936b2b43604d6d1753,当前分支 HEAD7ada13148777037a2e3d44bf37f9abf210600a80)后的本地复验验证环境:macOS arm64,Go 1.27.4,Rust 1.97.1,仓库固定 Core
076ce04e314ecdde790b36ee3f374becb11951a0。(cd desktop && gofmt -l .)、git diff --check origin/main...HEAD./scripts/desktop/desktop-go.sh vet ./...、./scripts/desktop/desktop-go.sh vet -tags dev ./..../scripts/desktop/desktop-go.sh test -race -count=1 ./internal/ai2.747s)ANTHROPIC_BASE_URL/ANTHROPIC_API_KEY/ANTHROPIC_MODEL/OPENAI_API_KEY/CODEX_HOME/CLAUDE_CONFIG_DIR/XDG_CONFIG_HOME/XDG_DATA_HOME/USERPROFILE/APPDATA)运行TestProviderDiscoveryUsesRealCoreParser(-race -count=1)2.249s)./.agents/skills/write-stable-tests/scripts/test-stability-macos.sh --package ./internal/aiTestProviderDiscoveryUsesRealCoreParser30ms;生成.artifacts/test-stability/index.html与macos-desktop-go.junit.xml)./scripts/desktop/desktop-go.sh test -race -count=1 -run 'TestAIGenerationSourcesFollowTheChosenProvider' ./internal/workbench3.141s)./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/main-race验证并人工复核)./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD与./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/agent-notes/verify-agent-notes.shnode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check、node --test --test-timeout=60000 scripts/i18n/test-i18n.mjs./scripts/desktop/verify/verify-runtime-bundle-immutability.sh、node --test scripts/desktop/verify/test-runtime-bundle-immutability.mjsnode scripts/desktop/validate-pins.mjs、插件零依赖rg自查、Shell 语法检查rg0 命中)未能执行的检查和原因: Windows 桌面测试与定时门禁、macOS/Windows 原生完整界面验收未在本地执行(待 PR ready 后由 CI 与原生验收覆盖)。
初版提交时(Linux amd64)验证记录
验证环境:Linux amd64,Go 1.27.4,Rust 1.100.0,当时固定 Core
dcb3d77f7a56e58f3d7c0aceea5b7df6986ed2e2。./internal/ai包scripts/desktop/desktop-go.sh test -p=1 -count=1 -timeout=180s ./...AF_UNIXEPERM失败,workbench 记录 10 个既有 Git 工作流失败并在 180 秒包期限到达时终止(已用基线 overlay 复核均在基线同因失败)提交前确认 / Final checks
main基线创建独立分支并已合并最新origin/main,目标为main。