Skip to content

fix: remove stale project path caching that caused cross-project misattribution#262

Merged
BYK merged 2 commits into
mainfrom
fix/project-path-misattribution
May 12, 2026
Merged

fix: remove stale project path caching that caused cross-project misattribution#262
BYK merged 2 commits into
mainfrom
fix/project-path-misattribution

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 12, 2026

Summary

  • Removed cachedProjectPath from pipeline.tshandleCompaction now calls getProjectPath() fresh on every request, matching handleConversationTurn's behavior
  • Changed buildIdleWorkHandler to read state.projectPath at call time instead of closing over a single projectPath captured at init — each session's idle work now uses the correct project
  • Added 22 tests for inferProjectPath/getProjectPath (20) and idle handler project isolation (2)

Root Cause

Two bugs caused all compaction and idle background work (distillation, curation, knowledge export) to run against whichever project the gateway saw first:

  1. handleCompaction (pipeline.ts:1597) preferred cachedProjectPath (frozen from the first request) over fresh inference. If the first request came from project A, all subsequent compaction requests for project B would use A's path.

  2. buildIdleWorkHandler (idle.ts:163) was constructed once with a single projectPath parameter captured in a closure. All sessions' idle work used that path, even though SessionState already had a correct per-session projectPath field.

Fix

  1. cachedProjectPath removed entirely — it had zero valid consumers after the fix. handleCompaction now matches handleConversationTurn's behavior of calling getProjectPath() fresh.
  2. buildIdleWorkHandler no longer takes a projectPath parameter — reads state.projectPath inside the handler instead.

BYK added 2 commits May 12, 2026 17:17
…ttribution

Two bugs caused knowledge entries and all idle background work to be
attributed to whichever project the gateway saw first:

1. handleCompaction preferred cachedProjectPath (frozen from the first
   request) over fresh getProjectPath() inference. Removed
   cachedProjectPath entirely — it has zero valid consumers.

2. buildIdleWorkHandler closed over a single projectPath parameter
   captured at init time. Changed to read state.projectPath at call
   time so each session's idle work uses the correct project.

Added tests for inferProjectPath/getProjectPath (20 tests) and idle
handler project isolation (2 tests) to prevent regression.
Run idle handler tests in a separate Bun process so mock.module
calls on @loreai/core don't leak into cache-warmer and other tests
that import the same module.
@BYK BYK merged commit 820d702 into main May 12, 2026
7 checks passed
@BYK BYK deleted the fix/project-path-misattribution branch May 12, 2026 17:27
This was referenced May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant