Skip to content

Make codebase-memory graph indexing opt-in (default OFF): 25s/init for an artifact nothing reads #323

Closed

Description

@abogartz

Parent

Sub-task of EPIC #315; resolves the actionable half of #317 (see the two proof comments there, 2026-11-06).

Problem

runInit calls ensureGraph (src/init/run.ts:154), which spawns codebase-memory-mcp cli index_repository on the first-write critical path. Proven waste:

  • Cost when it works: 11.5s in-process, ~26s end-to-end per init.
  • Nothing consumes the graph. codebase-memory is referenced only in src/init/* and tool descriptions; gate1 resolves refs against the live file tree. Gate evidence events are identical with the graph present or absent.
  • It usually fails anyway: across the interactive benchmark stores graph=unavailable ×29 vs graph=indexed ×3. The 3 successes were read by zero code paths.

So users pay ~25s on memory_init (part of the B1 cold-start tax) for an artifact no code path reads.

Change

Make graph indexing opt-in. Default OFF.

  1. Config flag (src/core/config/paths.ts, beside cbmBin): graphEnabled() returning true only when process.env.OPENCODE_MEMORY_GRAPH === "1". Default false.
  2. runInit (src/init/run.ts): when !graphEnabled(), skip the ensureGraph call entirely and set graph = { action: "disabled", mode }. Keep the existing path intact for opt-in. Stamp content already carries graph=${graph.action}, so it will read graph=disabled — no stamp format change.
  3. GraphStatus type (src/init/detect.ts): add "disabled" to the action union.
  4. Tool description (src/tools/init.ts): drop the "Ensures the codebase-memory graph for this repo is indexed (one-shot cli spawn…)" promise; state that graph indexing is opt-in via OPENCODE_MEMORY_GRAPH=1 and that memory works without it.
  5. init summary/format (src/init/format.ts): render Graph: disabled cleanly (no error tone).
  6. optionalDependency: KEEP codebase-memory-mcp. Opt-in still uses it; removing it is a separate decision that would break anyone who set the flag. Note this in the PR.

Tests

  • test/init.test.ts: default run asserts graph.action === "disabled" and that no cli spawn occurs (spy on Bun.spawn/run).
  • Opt-in test: with OPENCODE_MEMORY_GRAPH=1, ensureGraph is reached (stub the binary; do not require the real one in CI).
  • test/scenarios.test.ts / test/resolver.test.ts: update any assertion that expects graph=indexed/unavailable by default.

Docs

  • README: where it mentions the knowledge graph, state it is opt-in and off by default, and that retrieval/gates never required it.

Acceptance

  • Fresh repo, no env: memory_init returns in <1s, graph=disabled, zero codebase-memory-mcp spawns (assert in test).
  • OPENCODE_MEMORY_GRAPH=1: prior behavior preserved.
  • Gate evidence unchanged for a reference vs non-reference write pair (already identical today — this must stay true).
  • No regression in existing gate/write tests.

Out of scope

Building a graph consumer. If a future gate wants the index, it files its own ticket and flips the default back on with evidence that it reads the artifact.

Activity

  1. added
    enhancement
    severity:low
    on Nov 6, 2026
  2. abogartz-opencode-self-improvement commented on Nov 8, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.16.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

    enhancementreleasedseverity:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions