fix(memory): surface segments in the SL index for re-run gap targeting

The SL index shown to the agent on each re-run listed measures and joins but not segments, so repeat passes could not see which existing sources were thin on segments and re-derived blindly. The index now reports segment counts and names alongside measures, and a source is only flagged for enrichment when measures, segments, and joins are all empty.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Luca Martial 2026-06-25 17:15:27 -07:00
parent 9c0309c525
commit aa5cce3fd0

View file

@ -615,15 +615,19 @@ export class MemoryAgentService {
: sources
.map((s) => {
const measureCount = s.measures.length;
const segmentCount = s.segments?.length ?? 0;
const joinCount = s.joins?.length ?? 0;
const header = `${s.name} [measures=${measureCount}, joins=${joinCount}]`;
if (measureCount === 0 && joinCount === 0) {
const header = `${s.name} [measures=${measureCount}, segments=${segmentCount}, joins=${joinCount}]`;
if (measureCount === 0 && segmentCount === 0 && joinCount === 0) {
return `${header} — candidate for enrichment`;
}
const parts: string[] = [header];
if (measureCount > 0) {
parts.push(` measures: ${s.measures.map((m) => `${s.name}.${m.name}`).join(', ')}`);
}
if (segmentCount > 0) {
parts.push(` segments: ${(s.segments ?? []).map((seg) => seg.name).join(', ')}`);
}
if (joinCount > 0) {
parts.push(` joins: ${(s.joins ?? []).map((j) => `${j.to} (${j.relationship})`).join(', ')}`);
}