Skip to content

Scope global registry discovery to Git alias candidates - #9094

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/scope-git-alias-discovery-20261119
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/scope-git-alias-discovery-20261119

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Problem

The shared bootstrap code looked up the machine-wide registry before using the result of Git discovery. An already configured standalone project could fail in onboarding when the current and legacy machine registries both existed. This affected Codex App identity selection and Antigravity's onboarding and bootstrap previews.

Change

Resolve the global registry for alias discovery after Git identifies a common directory. The local project registry supplies the standalone preview. Git projects continue through canonical source selection. Operations that need a machine default continue to report ambiguous routing.

Validation

  • The three normal CLI previews fail on 45c015ffd9c9 and pass on 76d572ee0d13 with both machine defaults populated. The test verifies the local registry, agent choices and Antigravity's generated command route. It also checks the conflict for an unconfigured project and a real Git checkout.
  • 209 source tests pass with two platform skips. A separate real linked Git worktree continues to select the canonical source registry. The same standalone cases pass through the isolated installed wheel.
  • A trial merge with Honor the explicit runtime during host activation #8771 at 0c0d34f72678 passes the three standalone cases and preserves the explicit Codex App runtime and project registry in the generated quota command. Picking a Codex App Agent on a route that still asks for a machine default continues to report the conflict. Explicit runtime work
  • All 6 direct and 2 selected standard premerge checks pass. The strict quality gate remains blocked by identical Ruff and mypy failures on the immutable base and candidate. Existing static-check repair #9082

Independent review and hosted checks remain pending.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: model_agent · Gemini · Google (self_reported)

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

在同一台机器同时存在当前与遗留全局注册表且未显式覆盖运行时目录时,使用本地独立项目配置预览 Codex App 或 Antigravity 接入流程的用户和脚本会遇到这一问题。

修改前,即便非 Git 独立项目的本地注册表已经声明了独立的运行目录,引导连接检查仍会先探测机器默认全局注册表并因双目录冲突直接报错退出;修改后,引导流程只在检测到 Git 公共目录后才读取全局注册表,非 Git 独立项目直接按本地注册表完成只读预览。

已连接的非 Git 独立项目在默认全局注册表冲突下可稳定完成只读接入预览且不改写本地配置,未连接目录与 Git 仓库仍保留原有的默认路由冲突保护。 本次不修改机器默认运行目录的选择规则,也不为已经初始化为 Git 仓库的项目跳过全局工作树别名解析。 在基线提交上,已声明本地运行目录的非 Git 独立项目在三种正常预览命令下均会被误伤中断,而维持现状会让已经完成项目隔离配置的用户无法生成接入命令包,因此这是一处边界清晰且有实际价值的修复。

改动思路 / Approach

共享引导连接检查会在本地项目加载前调用工作树别名解析,判定当前目录是否属于某个已登记的主仓库,从而决定采用工作树指向的主仓库配置还是直接使用输入目录的 .loopx/registry.json。当目录本身不是 Git 仓库时,根本不可能匹配任何共享同一 Git 公共目录的全局别名候选,因此先完成 Git 发现再决定是否查询机器默认全局注册表。

场景 基线行为 (45c015ffd9c9) 当前 Head (76d572ee0d13)
非 Git 独立项目(已设 common_runtime_root,双全局表冲突) 先调用默认全局路径选择并抛出冲突异常 Git 公共目录为空时提前返回 applied=false,继续读本地注册表完成预览
Git 关联工作树(单默认或显式全局表) 解析到主仓库的规范 source_registry 保持不变,仍返回 git_worktree_canonical_source_registry
未连接目录或未设运行目录的 Git 项目(双全局表冲突) 抛出双全局注册表冲突错误 保持不变,继续显式暴露路由冲突

将 Git 公共目录发现放在机器全局注册表解析之前属于最小位置修复,只收窄触发全局默认路由读取的分支,不新增任何配置开关或第二套路径状态。 当前 PR 仅调整别名解析函数的求值顺序并补充独立项目只读预览回归测试,保留现有全部下游连接与注册表契约。 上游主调方在显式传入 global_registry 参数时,非 Git 路径同样跳过无意义的 JSON 读取,但仍保留返回值中的规范化路径字段以兼容调用习惯。

具体改动 / Changes

本次精确评审 head 为 76d572ee0d13ac5dbed76c146222a341269c3605,diff base 为 45c015ffd9c9065b3af533e0abf103170627d15f,共改动 2 个文件(+72 / -3 行):产品运行代码 loopx/project_alias.py(+13 / -3)与回归测试 tests/test_host_loop_activation.py(+59 / -0)。针对 problem_context.spec_basis,project_alias 与引导连接逻辑目前尚无独立成文的 accepted RFC 或协议规范文件,其行为边界由现有下游调用链和回归测试共同约束。

关键代码讲解

  • resolve_canonical_project_alias:首先计算 target_common_dir = _git_common_dir(resolved_project)。当其为 None 时直接返回 applied: False、kind: "none"、git_common_dir: None 与 reason: "git common-dir unavailable",且仅在调用方显式传入 global_registry 时才回填规范化路径字符串,未传时返回 None,避免调用 _default_global_registry_path() 触发 select_default_runtime_root() 冲突异常;仅当存在有效 Git 公共目录时,才解析并读取全局注册表及后续候选排序逻辑。
  • _inspect_bootstrap_connection 与 build_agent_onboarding_packet:二者共享连接探测链路。当非 Git 独立项目从 resolve_canonical_project_alias 收到 applied: False 后,继续使用输入项目自己的 .loopx/registry.json,并由 resolve_runtime_root 读取本地声明的 common_runtime_root,同时保留 canonical_project_alias.global_registry 为 None。
  • test_standalone_project_previews_use_their_declared_runtime_when_defaults_conflict:在同时写入默认和遗留全局注册表制造 conflict 状态后,验证非 Git 独立项目执行 agent-onboard(codex-app 与 antigravity-app)及 bootstrap-command-pack 均返回成功且本地注册表字节不变;随后分别验证未连接目录以及执行 git init 后的目录仍按预期抛出双默认注册表冲突错误。

对主干的风险 / Risks

本次改动未引入新状态字段或持久化格式,也不改变公共命令参数与权限语义。主要潜在边界风险在于:若一个独立项目已经本地配置了 common_runtime_root,同时自身目录下又执行过 git init 成为 Git 仓库,那么在未传 --runtime-root 且主机双默认全局表冲突时仍会报错。这一行为属于有意保留的边界——因为一旦存在 .git,目录就可能是需要回溯主仓库的关联工作树,贸然跳过全局注册表会破坏多工作树规范源识别。此外,所有已知直接调用方(引导命令包、cli_runtime、collaboration 附件快照与 peer 输入校验)均已核查,无任何调用方依赖非 Git 场景下未传参数时的 global_registry 非空字符串。

本地实测与基线对比结果如下:

  • 隔离测试套件(pytest 覆盖 test_host_loop_activation.py 等 6 个激活与引导测试文件):PASS(114 passed, 2 skipped),test_start_goal_compact_projection.py 别名与工作树用例 PASS(1 passed)。
  • 基线反事实对比(在当前 head 与 45c015ffd9c9 基线版本上分别运行双全局表冲突下的非 Git 独立项目 agent-onboard 预览):基线 FAIL 并抛出 ValueError: Both default LoopX registries exist,当前 head PASS 且关联工作树规范源测试 examples/bootstrap-command-pack-smoke.py PASS。
  • 静态检查与 premerge 门禁:ruff check PASS;mypy --strict --follow-imports=silent loopx/project_alias.py PASS(0 errors);测试文件全量 mypy --strict 仍报 25 条既有历史注解错误,经与 45c015ffd9c9 基线比对完全一致(0 条新增);loopx canary premerge --from-git-diff --git-diff-base 45c015ffd9c9065b3af533e0abf103170627d15f PASS(6 项直接检查与 2 项选中 canary 全部通过)。

我的整体评价 / Verdict

同意当前提交。改动用极小的控制流顺序调整准确消除了非 Git 独立项目在双默认注册表环境下的误报阻塞,同时完整保留了关联 Git 工作树规范源解析以及未连接/Git 冲突场景的保护语义。long_horizon 与 user_experience 均保持或改善,无 rendered UI 变更(visual_review 为 not_applicable;未验证范围为关联的其它未修改前端页面,本次未触及)。代码体量克制,架构边界清晰,无多余兼容分支或新增词汇;远端 CI 仍未作为依据(wait_for_ci: false),所有关键不变量均已在本地精确 head 76d572ee0d13ac5dbed76c146222a341269c3605 验证通过。

English verdict: APPROVE. At exact head 76d572e, moving Git common-dir discovery ahead of default global-registry selection unblocks standalone non-Git project previews under conflicting host defaults while preserving linked-worktree resolution and conflict diagnostics.

This branch has not been deployed

No deployments
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.

1 participant