feat(memory): state-keyed repo-map reuse via L3 presence check; embed entries on fresh scan

- Add existsByTurnIdPrefix(prefix) to L3MemoryStore interface; implemented in
  InMemoryL3MemoryStore (mutex-guarded) and TurboVecL3MemoryStore (metadata map).
  All test fakes (TrackingL3MemoryStore, CapturingStore) updated.
- Introduce RepoMapIndexerPort interface; RepoMapIndexer implements it. Allows
  injection of test doubles without framework overhead.
- ProjectMemoryService.indexAndRecord: reads latest WorkspaceStateObservedEvent
  from event store (invariant #9 — recorded fact, not re-probe); skips scan+embed
  when L3 already holds entries for "repomap:<root>:<stateKey>"; passes stateKey
  to RepoMapComputedEvent; embeds each scanned entry after append; per-entry
  failures warn-logged (CancellationException rethrown).
- Tests: InMemoryL3MemoryStoreTest +2 cases; new ProjectMemoryServiceReuseTest
  covers same-key skip, changed-key re-index, no-observation always-reindex,
  and embedding turnId tag verification.
This commit is contained in:
2026-06-11 13:30:57 +04:00
parent 4dbe637f4a
commit 9d38a89c88
9 changed files with 200 additions and 3 deletions
@@ -43,6 +43,9 @@ class TurboVecL3MemoryStore(private val config: TurboVecSidecarConfig) : Rehydra
metadata[entry.id] = entry
}
override suspend fun existsByTurnIdPrefix(prefix: String): Boolean =
metadata.values.any { it.turnId.startsWith(prefix) }
override suspend fun query(query: L3Query): List<L3Hit> {
val request = SidecarRequest(
op = "search",