(graphPath, outcome)
| 151 | } |
| 152 | |
| 153 | function recordToLocal(graphPath, outcome) { |
| 154 | try { |
| 155 | // Resolve the project dir once so the cwd tag and the workspace_id secret |
| 156 | // share a single, consistent source (both must agree with the session-start |
| 157 | // reader's resolveProjectDir()-based scoping). |
| 158 | const projectDir = resolveProjectDir(); |
| 159 | const entry = { |
| 160 | timestamp: new Date().toISOString(), |
| 161 | gene_id: outcome.geneId || 'ad_hoc', |
| 162 | signals: outcome.signals, |
| 163 | outcome: { |
| 164 | status: outcome.status, |
| 165 | score: outcome.score, |
| 166 | note: outcome.summary, |
| 167 | }, |
| 168 | // Tag the originating workspace so the review-time reader in |
| 169 | // collect.js can scope user-level fallback entries to the current |
| 170 | // cwd. Without this, two unrelated projects sharing the user-level |
| 171 | // fallback file (~/.evolver/memory/evolution/memory_graph.jsonl, |
| 172 | // used by npm-global installs) would cross-pollinate each other's |
| 173 | // review context — a prompt-injection / disclosure surface flagged |
| 174 | // by Bugbot on PR #105 round-2. |
| 175 | // |
| 176 | // workspace_id is the forge-resistant tag (PR #108 round-3): the |
| 177 | // reader compares it against the secret in the workspace's own |
| 178 | // .evolver/workspace-id file. cwd is retained as a backward-compat |
| 179 | // tag so older entries written before this hardening still pass |
| 180 | // the cwd check. |
| 181 | // |
| 182 | // Use resolveProjectDir() (NOT process.cwd()) so the cwd tag records the |
| 183 | // user's project, consistent with how the diff above is collected and |
| 184 | // with the session-start reader's cwd fallback. Under Cursor, cwd is the |
| 185 | // plugin install dir, so a raw process.cwd() tag would never match the |
| 186 | // reader's resolveProjectDir()-derived currentDir — silently hiding every |
| 187 | // cwd-only entry (Bugbot PR #555). collect.js only uses cwd as a legacy |
| 188 | // fallback (disabled once a workspace_id secret exists), so changing the |
| 189 | // tag's source — still a directory path — does not affect its scoping. |
| 190 | cwd: projectDir, |
| 191 | workspace_id: resolveWorkspaceId(undefined, projectDir), |
| 192 | source: 'hook:session-end', |
| 193 | }; |
| 194 | fs.appendFileSync(graphPath, JSON.stringify(entry) + '\n', 'utf8'); |
| 195 | return true; |
| 196 | } catch { |
| 197 | return false; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | // Append a single timestamped line to ~/.evolver/logs/evolution.log (or |
| 202 | // EVOLVER_HOOK_LOG_DIR). Best-effort: a log-write failure must never break the |
no test coverage detected