Skip to content

test: 9 suites statically import path-resolving modules without redirecting CLAUDE_CONFIG_DIR #171

Description

@ramarivera

Follow-up to #164 (which fixed the live-state clobbering in server/state.test.ts).

Status: latent, not currently leaking. Verified on main + #170: a full bun test with CLAUDE_CONFIG_DIR unset and HOME pointed at a temp dir writes no buddy state under the fake home, and a run with the real environment leaves every file in the live state dir untouched except the .substatus.* caches the running statusline owns.

The hazard shape. These files statically import a module that resolves buddy/Claude paths, and never redirect CLAUDE_CONFIG_DIR:

  • adapters/omp/extension.test.ts
  • adapters/pi/events.test.ts
  • adapters/pi/renderers.test.ts
  • adapters/shared/file-storage.test.ts
  • adapters/shared/widget-layout.test.ts
  • core/command-service.test.ts
  • core/identity.test.ts
  • server/statusline.test.ts
  • server/uninstall.test.ts

server/state.test.ts carries a REGRESSION GUARD comment explaining exactly why this is dangerous — the same shape silently overwrote a live companion on every bun test. Today these 9 stay safe only because they happen not to hit a write path with default-resolved paths. That is a property of the current test bodies, not of the setup.

Suggested fix: a shared test bootstrap that points CLAUDE_CONFIG_DIR at a temp dir before any import, so isolation is structural rather than incidental.

🤖 Created with the help of AI (Claude Opus 5).

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions