fix(memory): fire SL capture signal for SQL-bearing external ingest

The SQL-aggregate signal gated on userMessage.length >= 100, but `ktx ingest --file` sets a fixed boilerplate user message and carries the artifact in the assistant message. SQL-heavy files therefore never force-loaded the SL capture skill and defaulted to wiki capture. External ingest now treats the deliberate submission itself as the substantive signal, so verified SQL fires the SL signal regardless of the boilerplate user message.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Luca Martial 2026-06-25 17:15:15 -07:00
parent 77c38e9ea2
commit 84d329b24b
2 changed files with 36 additions and 1 deletions

View file

@ -31,6 +31,31 @@ describe('MemoryAgentService.detectCaptureSignals', () => {
expect(result.sl).toBe(false);
});
it('fires sl on assistant SQL for external_ingest despite a short boilerplate user message', () => {
// `ktx ingest --file` keeps the content in assistantMessage and uses a fixed boilerplate
// user message, so the substantive-turn gate must come from the deliberate submission itself.
const result = detectCaptureSignals({
userId: 'u',
chatId: 'c',
userMessage: 'Ingest external text artifact "verified_pairs.md" into ktx memory.',
assistantMessage: 'Q: total claims completed?\nSQL: SELECT COUNT(DISTINCT Claim_No_Date) FROM dimJob_Details',
sourceType: 'external_ingest',
});
expect(result.sl).toBe(true);
expect(result.reasons).toContain('sql aggregate in assistant message');
});
it('keeps the substantive-turn gate for non-ingest source types with a short user message', () => {
const result = detectCaptureSignals({
userId: 'u',
chatId: 'c',
userMessage: 'Ingest external text artifact "verified_pairs.md" into ktx memory.',
assistantMessage: 'SELECT COUNT(DISTINCT Claim_No_Date) FROM dimJob_Details',
sourceType: 'research',
});
expect(result.sl).toBe(false);
});
it('fires sl on definition keywords in user message regardless of length', () => {
const result = detectCaptureSignals({
userId: 'u',