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

@ -16,8 +16,18 @@ export function detectCaptureSignals(input: MemoryAgentInput): CaptureSignals {
const assistantMessage = input.assistantMessage?.trim() ?? '';
const reasons: string[] = [];
// The user-message length gate is a research-path proxy for "the turn was substantive
// enough to promote the assistant's SQL." External ingest carries a fixed boilerplate
// user message and keeps the real content in the assistant message, so the proxy never
// holds there - treat the deliberate submission itself as the substantive signal.
const deliberateSubmission = input.sourceType === 'external_ingest';
let sl = false;
if (assistantMessage && SQL_AGGREGATE_PATTERN.test(assistantMessage) && userMessage.length >= 100) {
if (
assistantMessage &&
SQL_AGGREGATE_PATTERN.test(assistantMessage) &&
(deliberateSubmission || userMessage.length >= 100)
) {
sl = true;
reasons.push('sql aggregate in assistant message');
}