Skip to content

Drop the code-graph integration from /repo-init - #368

Merged
abogartz merged 3 commits into
mainfrom
231-remove-graph
Nov 9, 2026
Merged

abogartz merged 3 commits into
mainfrom
231-remove-graph

Conversation

@abogartz

@abogartz abogartz commented Nov 9, 2026

Copy link
Copy Markdown
Owner

What this does

/repo-init used to be able to build a code-graph index with an external tool called codebase-memory-mcp. This removes that integration.

It was worth removing because nothing ever read the index back. The plugin resolves code references (a memory that names a file or a constant) by looking at the live files on disk, and the write-gate audit trail comes out byte-identical whether the index exists or not. So the feature cost:

  • an optionalDependencies pin on a third-party package, and the install that comes with it;
  • a spawn of that third-party binary inside the user's own repository — a supply-chain surface for a result nobody consumed;
  • 11-26 seconds on the critical path of a first init, which failed in 29 of 32 real runs;
  • a documented tool argument (mode), two environment variables, a README section, and a troubleshooting row.

Indexing stays an operator-side concern: anyone who wants the graph can run that tool as its own MCP server. The plugin no longer has an opinion or a subprocess.

What changes for a user

  • /repo-init is local-only: parse manifests, write the command memories, write the stamp. No subprocess, ever. There is now a test asserting exactly that.
  • The reply no longer has a Graph: … line, and memory_init no longer takes a mode argument.
  • The stamp row no longer carries graph= / mode=. Stamps are matched on git head, so existing stamps keep working; the next init rewrites the line in the new shape.
  • OPENCODE_MEMORY_GRAPH and OPENCODE_CBM_BIN do nothing.

One stale comment went with it: the write-gate resolver's header claimed it cross-checked references against the graph when OPENCODE_CBM_BIN was set. It never did — the comment now describes the code.

Note on names: the gate's own audit lines graph_current and graph_drift stay. They are the gate re-reading the live file tree to see whether a remembered file path still exists — the word "graph" there predates this integration and has nothing to do with it.

Tests

  • bun run gate green: 1104 unit tests + 30 terminal/BDD tests against a real host, 0 fail.
  • bunx tsc --noEmit clean; bun run lint identical to main's baseline.
  • The old opt-in tests (fake binary, spawn spy) are replaced by one test that fails if any child process is spawned during init.

Breaking in the strict sense (one tool argument and two env vars disappear), with no behavior lost — the decision is recorded on the ticket.

Closes #231.

Nothing in src ever read the index back: gate1 resolves code refs against the
live file tree, and gate evidence is identical with the index present or absent.
What the integration cost was an optionalDependency pin, a three-step binary
discovery path, a published schema enum, and a supply-chain surface — /repo-init
could spawn a pinned third-party binary inside the user's repository. Measured
on the benchmark it also cost 11-26s on the first-write critical path and failed
in 29 of 32 real inits.

Removed: ensureGraph/cbmProject and the graph status line, cbmBin()/graphEnabled(),
the mode argument (tool schema, wire snapshot, InitArgs), the optionalDependency
and its lockfile entry, the OPENCODE_CBM_BIN/OPENCODE_MEMORY_GRAPH docs, the
Code graph section and its troubleshooting rows, and the graph assertions in the
init and characterization suites. The init stamp no longer carries graph= and
mode=; stamp matching keys on head, so existing stamps keep working.

Fixed on the way out: the GATE-1 resolver header claimed it cross-checked refs
against the graph when OPENCODE_CBM_BIN was set. It never did — the comment is
now what the code does.

The gate names graph_current/graph_drift stay: they are GATE-1's own ref-freshness
read of the live tree, unrelated to the removed indexer.

Test: memory_init now asserts the opposite of the old opt-in proof — no Bun.spawn
call at all for any argument set. Merge gate green: 1104 unit + 30 e2e, tsc clean,
lint identical to main's baseline.
@abogartz

abogartz commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Adversarial self-review (author-side, not independent)

Checked the removal against current main rather than the branch point. What I verified, then what I found.

Verified clean:

  • No orphan references. graphEnabled, cbmBin, ensureGraph, GraphStatus, OPENCODE_MEMORY_GRAPH, OPENCODE_CBM_BIN are gone from every read path; the only remaining mentions are the "this was removed (Decide the codebase-memory graph: wire it into the resolver or delete the integration #231)" comments.
  • Old stamps still work. initStamp() parses only head= by regex, so a stamp written by the old format (..., graph=disabled, mode=moderate, scripts=N) is still read and still suppresses a re-init. No forced re-init on upgrade.
  • The run() spawn helper in run.ts had exactly one consumer (cbmProject); removing both is consistent.
  • formatInit stays covered after the spy deletion: e2e/characterization.test.ts asserts "Initialized " and test/init.test.ts asserts "Initialized repo" through the tool, so the renderer is not untested.
  • git merge-tree against current main (post-0.21.0): clean, no conflicts.

Findings:

  1. 🟡 Dead import. src/core/config/paths.ts:7 still imports fileURLToPath from node:url; its only user was the deleted cbmBin(). biome lint does not fail on it (CI is green), so it will ride in silently. Delete the line.

  2. 🟡 The BREAKING is sharper than "the argument is gone". The wire schema is additionalProperties: false (asserted in test/boundaries.test.ts), so a caller or a host with a stale cached tool schema that still sends mode: "fast" gets a hard validation rejection, not a silently stripped key. That is acceptable for a BREAKING release, but the README is the only migration surface here and it should say, in one line, that old calls with mode now fail outright.

  3. 🔵 Optional: the deleted test "default: no graph spawn occurs" was the guard against an external binary ever being spawned from init. With the feature gone there is nothing to guard, which is fine — but a 5-line Bun.spawn spy asserting zero calls during init.execute({}) would stop the integration creeping back through a future "helpful" PR.

Verdict: approve after (1). (2) is a doc line, (3) is optional. Branch is 23 commits behind main; merge-tree is clean, so a merge of origin/main before landing is mechanical.

@abogartz
abogartz merged commit c50c376 into main Nov 9, 2026
4 checks passed
@abogartz

abogartz commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Merged into main at c50c376 with admin override (solo author; protection wants an approving review of the current head).

Before landing, per the self-review: dropped the dead fileURLToPath import in paths.ts and added the README troubleshooting row saying a stale call that still sends mode is rejected outright and that old graph=/mode= stamps still read.

Then merged origin/main (the four PRs that landed first). Two conflicts, both as predicted: src/init/run.ts imports — kept #372's quarantineCandidate, dropped graphEnabled; and test/init.test.ts — kept this branch's no-mode force test and the new no-spawn guard, kept main's init internals block including #371's crafted-key test, and de-graphed the formatInit test (Initialized x replaces the Graph: assertion). Post-merge: typecheck clean, 1188 unit tests, e2e 30/30.

@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.22.2 🎉

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decide the codebase-memory graph: wire it into the resolver or delete the integration

1 participant