Skip to content

Fix non-default CODEX_HOME state resolution #1

Description

@zendext

背景

Track the implementation of kxn/codex-remote-feishu#904 in this fork.

The daemon passes CODEX_HOME to headless Codex children, but its persisted thread catalog and turn-patch storage still derive paths from $HOME/.codex. The generated systemd and launchd service definitions also omit an explicitly selected CODEX_HOME.

目标

Use one resolved Codex home across headless children, persisted thread discovery, turn-patch storage, and managed service restarts while preserving the existing $HOME/.codex fallback.

完成标准

  1. A valid non-empty CODEX_HOME resolves the default SQLite catalog to $CODEX_HOME/state_5.sqlite.
  2. Turn-patch session and state paths derive from the same resolved Codex home ($CODEX_HOME/sessions and $CODEX_HOME/codex-remote-feishu/current-thread-patches).
  3. An unset CODEX_HOME preserves the current $HOME/.codex behavior.
  4. Generated systemd and launchd service definitions preserve the selected CODEX_HOME.
  5. Focused regression tests cover custom and default resolution plus managed-service rendering.
  6. User-facing installation documentation explains the supported non-default CODEX_HOME behavior.

建议范围

  • internal/codexstate:统一默认 Codex Home、SQLite catalog、sessions 与 turn-patch state 的路径解析。
  • internal/app/daemon:让生产构造调用复用同一个已解析 Codex Home。
  • internal/app/install:在 systemd 与 launchd 定义中保留显式 CODEX_HOME。
  • docs/general/user-guide.md:说明非默认 CODEX_HOME 的安装与自动启动行为。
  • 对应 focused tests 与仓库验证。

实现参考

  • 复用 internal/config/codex_model_provider_env.go 已有的 CODEX_HOME 目录校验语义。
  • 将默认 Codex Home 解析收敛到 internal/codexstate 的单一 helper,供 SQLite catalog 与 turn-patch storage 共用。
  • managed service 渲染只持久化明确设置且已校验的 CODEX_HOME,不改变未设置时的默认环境。

检查参考

  • go test ./internal/codexstate
  • go test ./internal/app/daemon
  • go test ./internal/app/install
  • scripts/check/pre-commit.sh

收尾参考

  • 使用 raw git 创建英文 conventional commit。
  • 通过 ./safe-push.sh 推送任务分支。
  • 创建包含 Closes #1、验证记录和文档影响的 draft PR。

执行决策

  • 是否拆分:否;SQLite catalog、turn-patch storage 与 managed service 环境属于同一个 CODEX_HOME 路径合同,拆开会形成中间不一致状态。
  • 当前执行单元:fork Issue Fix non-default CODEX_HOME state resolution #1。
  • verifier 决策:不运行独立 verifier;该变更不涉及安全、迁移或状态机,由父执行者完成 focused tests、pre-commit 和最终 diff 复核。

当前执行单元

Review upstream draft PR kxn#905 for commit efe31edc; do not mark it ready or merge it without explicit authorization.

下一步

Inspect upstream draft PR kxn#905 checks and review feedback. Mark ready or merge only after explicit authorization for that PR.

最后一致状态

Commit efe31edc implements the shared resolution and persisted install-state contract. Focused tests, go test ./... -count=1, and scripts/check/pre-commit.sh passed. The branch was published through safe-push.sh, fork draft PR #2 and upstream draft PR kxn#905 are open, and a local install verified that install state and the daemon process preserve the selected CODEX_HOME.

未完成尾项

  • Add regression tests.
  • Implement shared Codex home resolution.
  • Wire persisted catalog and turn-patch storage.
  • Preserve CODEX_HOME in systemd and launchd definitions.
  • Update user documentation.
  • Run repository verification and open a draft pull request.
  • Review upstream draft PR fix(codex): 支持非默认 CODEX_HOME kxn/codex-remote-feishu#905 and its checks.
  • Mark ready or merge only after explicit authorization.
  • Complete post-merge cleanup and close-out.

执行快照

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:codexCodex protocol translation and wrapper integrationarea:daemonDaemon server, admin API, and runtime controlbugSomething isn't workingprocessingClaimed for active issue handling in the current turnstatus:implementable-nowReady to implement with current issue body and context

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions