Skip to content

Magic Context fails to load when Git reports “detected dubious ownership in repository” #214

Closed

Description

@mplawner

Short description

Magic Context fails to load when Git reports “detected dubious ownership in repository”

What happened?

What happened:
Magic Context plugin is added to opencode.json and reports “plugin enabled”, but when opening a session in a directory where Git reports “fatal: detected dubious ownership in repository”, OpenCode logs:

failed to load plugin @cortexkit/opencode-magic-context@latest error="git rev-list failed while resolving project identity"

Magic Context never registers the project (no “dreamer registered project …” lines), does not start its RPC server, and sessions in that directory do not get /ctx-* commands. No sessions are recorded in session_meta.

What I expected:
Magic Context should:

Bind to the project and register it with dreamer.

Start its RPC server.

Expose /ctx-* slash commands in all sessions for that project.

Record sessions in its DB.

Repro steps:

Install Magic Context plugin in a normal OpenCode setup.

In a Git repo directory, ensure Git fails with “fatal: detected dubious ownership in repository” (e.g., by not adding the path to safe.directory).

Start opencode serve.

Open a session in that directory.

Observe:

“failed to load plugin ... error='git rev-list failed while resolving project identity'” in OpenCode logs.

Magic Context logs show “plugin enabled” but no “dreamer registered project” and no “rpc server listening”.

No /ctx-* commands in that session.

session_meta has 0 rows.

Fix:
Adding the directory to Git’s safe list:
git config --global --add safe.directory /path/to/project
Then restarting the server makes Magic Context load, bind to sessions, and expose /ctx-*.

Diagnostics

## Description
What happened:

## Environment
- Plugin: v0.30.7
- OS: linux arm64
- Node: v22.22.3
- OpenCode: 1.17.13

## Configuration
Config from `~/.config/cortexkit/magic-context.jsonc`:

{
  "$schema": "https://raw.githubusercontent.com/cortexkit/magic-context/master/assets/magic-context.schema.json",
  "historian": {
    "model": "opencode-go/deepseek-v4-flash"
  },
  "dreamer": {
    "model": "opencode-go/deepseek-v4-flash"
  },
  "sidekick": {
    "disable": true
  }
}


## Diagnostics
- Timestamp: 2026-07-05T17:19:41.009Z
- Plugin: v0.30.7
- OS: linux arm64
- Node: v22.22.3
- OpenCode installed: true [cli] (1.17.13)
- Plugin registered in opencode config: true
- Plugin registered in tui config: true
- magic-context.jsonc parse error: none
- Conflicts detected: none

### Config paths

{
  "configDir": "~/.config/opencode",
  "opencodeConfig": "~/.config/opencode/opencode.json",
  "opencodeConfigFormat": "json",
  "magicContextConfig": "~/.config/cortexkit/magic-context.jsonc",
  "tuiConfig": "~/.config/opencode/tui.jsonc",
  "tuiConfigFormat": "jsonc",
  "omoConfig": null
}


### magic-context.jsonc flags

{
  "$schema": "https://raw.githubusercontent.com/cortexkit/magic-context/master/assets/magic-context.schema.json",
"historian": {
    "model": "opencode-go/deepseek-v4-flash"
  },
  "dreamer": {
    "model": "opencode-go/deepseek-v4-flash"
  },
  "sidekick": {
    "disable": true
  }
}


### Plugin cache

{
  "path": "~/.cache/opencode/packages/@cortexkit/opencode-magic-context@latest",
  "cached": "0.30.7",
  "latest": "0.30.7"
}


### Storage

{
  "path": "~/.l<USER>al/share/cortexkit/magic-context",
  "exists": true,
  "context_db_size": "6.2 MB"
}


### Recent sessions
_No recent OpenCode sessions found (or OpenCode DB unavailable on this runtime)._

### Historian dumps
(Metadata only — XML content is not included in this report.)
Dumps are stored per-project under `<project>/.cortexkit/magic-context/historian/`.

{
  "byProject": [],
  "legacyDumps": {
    "dir": "/tmp/opencode/magic-context/historian",
    "count": 0,
    "recent": []
  }
}


### Historian failures (session_meta)
_Note: this counter RESETS to 0 on every successful run — see 'Historian runs' below for the durable history._
_No sessions with historian failures._

### Historian runs (durable telemetry)
Per-session success/failure/no-op counts from `historian_runs` (never reset).
_No historian runs recorded (or schema predates v24)._

### Log file
- Path: /tmp/opencode/magic-context/magic-context.log
- Exists: true
- Size: 291 KB

## Historian failure signals (log, sanitized)
_No historian failure log lines found in recent history._

## Recent errors (last 20, sanitized)

[2026-07-05T15:01:13.926Z] [session-projects] background runner failed: ProjectIdentityError: git rev-list failed while resolving project identity
[2026-07-05T15:35:51.907Z] [session-projects] background runner failed: ProjectIdentityError: git rev-list failed while resolving project identity
[2026-07-05T16:10:37.800Z] [session-projects] background runner failed: ProjectIdentityError: git rev-list failed while resolving project identity


## Log (last 400 lines, sanitized)
---> Sorry, wasn't as sanitized as I was comfortable with. Suggest you remove project specific directory names when sanitizing.

Plugin version

No response

OpenCode version

No response

Platform

No response

Client

OpenCode Desktop

Log output (optional)

Activity

  1. alfonso-magic-context commented on Jul 6, 2026

    @alfonso-magic-context
    Contributor

    Fixed in v0.31.0. Git identity failures no longer prevent the plugin from loading:

    • A dubious ownership refusal (and git timeouts, missing git, or other transient failures) now falls back to a directory-based project identity instead of failing plugin load or the transform pass.
    • For dubious ownership specifically, you get a one-time warning with the exact fix: git config --global --add safe.directory <path>. Once git works again, the session picks the real repository identity back up, and identities resolved earlier in the process are reused during transient failures so project memory does not split.

    Update with npx @cortexkit/magic-context@latest doctor (or let auto-update pick up 0.31.0) and this environment should work without any git configuration. Thanks for the precise report — the log line pointed straight at the load-path gap.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions