(repoRoot, env = {})
| 141 | // captured at first import via getWorkspaceRoot(), so we run each scenario |
| 142 | // in a child node process with EVOLVER_REPO_ROOT pointed at a fresh dir. |
| 143 | function runInChild(repoRoot, env = {}) { |
| 144 | const script = ` |
| 145 | const collect = require(${JSON.stringify(path.resolve(__dirname, '..', 'src', 'evolve', 'pipeline', 'collect.js'))}); |
| 146 | console.log(JSON.stringify({ |
| 147 | mem: collect.readMemorySnippet(), |
| 148 | usr: collect.readUserSnippet(), |
| 149 | sess: collect.readRealSessionLog(), |
| 150 | })); |
| 151 | `; |
| 152 | // Cross-platform homedir: `os.homedir()` reads HOME on POSIX but |
| 153 | // USERPROFILE on Windows. The user-level memory_graph fallback in |
| 154 | // src/evolve/pipeline/collect.js calls `os.homedir()` directly, so |
| 155 | // setting only HOME (as the original test setup did) left Windows |
| 156 | // runs falling back to the developer's real $USERPROFILE instead |
| 157 | // of the test fixture — every workspace-id scoping test then |
| 158 | // returned `[MEMORY.md MISSING]` because the seeded fixture file |
| 159 | // wasn't where the reader looked. Mirror HOME into USERPROFILE so |
| 160 | // the same test passes on both platforms. |
| 161 | const childEnv = { |
| 162 | ...process.env, |
| 163 | EVOLVER_REPO_ROOT: repoRoot, |
| 164 | EVOLVER_NO_PARENT_GIT: 'true', |
| 165 | EVOLVER_QUIET_PARENT_GIT: '1', |
| 166 | EVOLVER_SESSION_SOURCE: 'cursor', |
| 167 | EVOLVER_CURSOR_TRANSCRIPTS_DIR: path.join(repoRoot, '__nope__'), |
| 168 | OPENCLAW_WORKSPACE: repoRoot, |
| 169 | AGENT_SESSIONS_DIR: path.join(repoRoot, '__nope__'), |
| 170 | HOME: repoRoot, |
| 171 | ...env, |
| 172 | }; |
| 173 | childEnv.USERPROFILE = childEnv.HOME; |
| 174 | const res = spawnSync(process.execPath, ['-e', script], { |
| 175 | env: childEnv, |
| 176 | encoding: 'utf8', |
| 177 | }); |
| 178 | if (res.status !== 0) { |
| 179 | throw new Error(`child failed: ${res.stderr || res.stdout}`); |
| 180 | } |
| 181 | const lastLine = res.stdout.trim().split('\n').pop(); |
| 182 | return JSON.parse(lastLine); |
| 183 | } |
| 184 | |
| 185 | it('returns legacy MISSING placeholders when no fallback sources exist', () => { |
| 186 | const tmp = mkTmp(); |
no test coverage detected