Repository navigation
feat(init): make codebase-memory graph indexing opt-in (default off) - #324
Conversation
runInit skips ensureGraph unless OPENCODE_MEMORY_GRAPH=1. Measured: the one-shot index spawn cost 11-26s per init, failed 29/32 real runs, and no read or gate path consumes the index (gate evidence identical with/without). memory_init 25s -> 0.13s; gate behavior unchanged. - paths.ts: graphEnabled(); correct stale 'resolver cross-checks the graph' comment - detect.ts: GraphStatus action adds 'disabled' - run.ts: gate the spawn; skip-path reports this build's state, not the prior stamp's - tools/init.ts + command/repo-init.md: drop the graph-index promise - init.test.ts: default no-spawn + opt-in reaches-binary (marker script); hermetic env - README: code graph now opt-in; env table + troubleshooting updated Refs #323, #317, #315
WhollyMindless
left a comment
There was a problem hiding this comment.
Reviewed 7f965c0b2b25025b29d000cbfd8ad4ae1cad6c65 against the human-authored #323 contract.
F1 — make the new graph-spawn fixture work on Windows (test/init.test.ts:91–102). The opt-in test writes an extensionless #!/bin/sh executable and launches it through Bun.spawn([fake, ...]). On native Windows this fixture does not execute: the expected marker is absent. I reproduced the same failure locally with Bun 1.4.4: bun test ./test/init.test.ts ./test/scenarios.test.ts ./test/resolver.test.ts gives 35 pass, 1 fail, at expect(existsSync(marker)).toBe(true). Hosted Windows fails at the same assertion (job log). This failure is independent of contention or timeout margins.
Please use a cross-platform spawn fixture or a narrowly scoped Bun.spawn spy, retaining both the no-spawn default assertion and an opt-in positive control. Merely skipping the opt-in test would lose the requested Windows coverage. A successful-index result is also useful: Graph: unavailable alone cannot distinguish reaching the fixture from failing to launch it.
The small production change looks consistent with #323. My separate temporary probe intercepted only the synthetic graph command and verified exact "1" flag semantics, zero graph spawns for unset/0/true, successful opt-in indexing, preserved command detection, and the disabled state on a repeated init (1 pass, 19 assertions). Optional dependency retained; no tracked source changes made. This is not a full-suite or live-host performance verification.
The hosted job also has six concurrency failures; I have not reproduced or attributed those to this diff. The independently reproduced PR-owned test failure above is the requested change.
…iew F1) The extensionless #!/bin/sh fixture never executes on Windows, so the opt-in test failed there and the default no-spawn assertion passed only trivially. Replace both marker-script fixtures with a narrowly scoped Bun.spawn spy: the default test proves zero spawns against a fake that would answer successfully, the opt-in test adds a successful-index positive control (Graph: indexed (repo), argv asserted), and a third test keeps the failing-binary degradation. Cross-platform, hermetic.
|
F1 fixed in d7c6340. Both marker-script fixtures replaced with a narrowly scoped
The spy patches only Local: The six concurrency failures ( |
|
CI after |
WhollyMindless
left a comment
There was a problem hiding this comment.
Rechecked head d7c6340fd23f396c0b5312f1fd6d05757a94ec9c. F1 is resolved; this approval supersedes my earlier changes request.
The delta from the reviewed head changes only test/init.test.ts. The scoped spawn spy restores in finally, leaves git probing untouched, asserts zero graph spawns by default, and exercises both successful indexing (including configured binary, repository path and mode) and exit-failure degradation. The extensionless shell fixture is gone.
Independent native Windows / Bun 1.4.4 verification: the same three focused suites now pass, 37 tests / 206 assertions / 0 failures; typecheck passes. All four hosted checks, including Windows, are green at this head. I did not rerun the full suite or live-host timing benchmark; the earlier six concurrency failures remain unattributed by me. No remaining blocking finding from my review; merge timing remains the maintainer's decision.
|
🎉 This PR is included in version 0.16.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Problem
memory_initbuilt acodebase-memorygraph on every run, and nothing consumed it.Measured on this repository before the change:
ensureGraph— 11.5 smemory_initend to end — ~26 sThe graph is not read by the write gate. Gate evidence (
graph_current,graph_drift) comes from gate1's live file-tree scan, so gate decisions are identical with the graph on or off. The benchmark stores confirmed the same thing from the other side: 29 runs reportedgraph=unavailableagainst 3 that reportedindexed, with no difference in gate outcomes.Keeping a 26 s step that nothing reads is not a good default.
Change
Graph indexing is now opt-in via
OPENCODE_MEMORY_GRAPH=1. Default is off.src/core/config/paths.ts—graphEnabled(); also corrects a stale comment that claimed the resolver cross-checks the graph.src/init/run.ts—runInitskipsensureGraphunless enabled, and the skip path no longer reportsindexed.src/init/detect.ts—GraphStatusgains"disabled".src/tools/init.ts,command/repo-init.md,README.md— surface the new state and the opt-in.test/init.test.ts— two spawn-proof tests using a marker script: default performs no spawn, opt-in reaches the binary.Evidence
opencode runagainst this build:memory_init0.13 s, reportsGraph: disabled, zerocodebase-memoryspawns, scripts still remembered.e2e/characterization.test.ts, which pins the host-facingmemory_initoutput shape and did not allow the new state. That contract now acceptsdisabled(7f965c0), and the full gate is green.Risk
Users who want the graph set
OPENCODE_MEMORY_GRAPH=1. Nothing else changes: store, gates, injection and recall are untouched.Closes #323