Skip to content

fix(state): derive own plugin data dir to avoid cross-plugin leak#1

Closed
suharvest wants to merge 1 commit into
tasict:mainfrom
suharvest:pr/fix-state-isolation
Closed

fix(state): derive own plugin data dir to avoid cross-plugin leak#1
suharvest wants to merge 1 commit into
tasict:mainfrom
suharvest:pr/fix-state-isolation

Conversation

@suharvest

Copy link
Copy Markdown

Summary

  • CLAUDE_PLUGIN_DATA can be exported into the shared env by an unrelated plugin (e.g. a codex companion). When that happens, opencode-companion's state lands in that plugin's data directory instead of its own.
  • Derive our own plugin data dir from the script's install path. Claude Code installs plugins at <root>/plugins/cache/<owner>-<repo>/<plugin>/<version>/... and assigns per-plugin data at <root>/plugins/data/<plugin>-<owner>-<repo>/, so the mapping is deterministic.
  • Fall back to CLAUDE_PLUGIN_DATA only when its basename already matches opencode; otherwise ignore it.
  • Add OPENCODE_COMPANION_DATA as an explicit opt-in override for users who want a custom location.

Test plan

  • Verified locally: jobs written under the opencode-scoped plugins/data/opencode-* dir even when CLAUDE_PLUGIN_DATA points at another plugin
  • Running from repo source (no plugins/cache/... layout) still falls back to /tmp/opencode-companion
  • Existing workspaces keep working (path hashing is unchanged)

CLAUDE_PLUGIN_DATA can be exported by an unrelated plugin (e.g. codex
companion) into the shared env, causing opencode state to land in
another plugin's data directory. Derive our own data dir from the
script's install path instead, falling back to CLAUDE_PLUGIN_DATA only
when it already names an opencode-scoped dir. Add OPENCODE_COMPANION_DATA
as an explicit override.
@suharvest

Copy link
Copy Markdown
Author

Superseded by #5 — consolidated hardening suite including this PR's work plus server/auto-heal/SAFETY_HEADER/wait-and-result on top. Closing since no review activity in 2+ days and the follow-on work builds on this.

@suharvest suharvest closed this Apr 19, 2026
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