Skip to content

bug(ai): module-level home-derived constants outlive the now call-time trusted home #4786

Description

@Yeachan-Heo

Summary

packages/utils now resolves the authoritative home at call time (#4761 / #4772): getTrustedHomeDir(), getConfigRootDir(), getAgentDir() and friends re-derive on every access and rebuild their caches when the home changes. Several downstream consumers still capture a home-derived path into a module-level constant at import time, so they keep pointing at the home that was in effect when their module first loaded.

Concrete instance:

// packages/ai/src/auth-broker/remote-store.ts:78
const DEFAULT_PRESENTATION_SIDECAR = path.join(getConfigRootDir(), "auth-broker-presentations.json");

getConfigRootDir() is call-time; the constant built from it is not.

Why it matters

This is the same shape as the original #4761 defect, one layer out. If the resolved home changes after that module loads, the resolver moves and this consumer does not, so a process can read and write one logical profile through two different roots — exactly the split that made user-scope skills and MCP disappear.

The credential angle deserves specific attention: the sidecar holds auth-broker presentations, and <configRoot>/.env is one of the files $credentialEnv treats as trusted. A stale root here is a credential-coherence question, not just a path-tidiness one.

Scope

This is pre-existing and out of scope for #4772:

Raised separately rather than expanded into a regression fix that already carries a needs-human verdict.

Suggested work

  1. Sweep for module-level constants derived from getConfigRootDir() / getAgentDir() / getTrustedHomeDir() and move them to construction or use time.
  2. Add regression coverage proving a consumer follows a post-load home change, ideally parent/child (a child inherits GJC_CODING_AGENT_DIR, so both must resolve one profile to one lane).
  3. Decide explicitly whether any consumer should pin an import-time root; if so, document why, rather than leaving it implicit.

Found during independent critic review of #4772.


[repo owner's gaebal-gajae (clawdbot) 🦞]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions