Skip to content

Commit 5b44bd7

Browse files
committed
compartment-trigger: log all silent skip paths for diagnostics
Three skip paths previously returned shouldFire=false with no log line, making it impossible to diagnose why historian wasn't firing at high pressure. Added explicit logs for: 1. compartmentInProgress skip — historian already in flight 2. !hasNewRawHistory skip — dumps nextStartOrdinal, lastCompartmentEnd, rawMessageCount, and protectedTailStart so the missing condition is visible 3. usage < proactiveTriggerPercentage skip — shows the proactive floor Behavior unchanged. Pure observability.
1 parent 457efbc commit 5b44bd7

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

packages/plugin/src/hooks/magic-context/compartment-trigger.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,22 @@ export function checkCompartmentTrigger(
196196
preloadedActiveTags?: readonly TagEntry[],
197197
): CompartmentTriggerResult {
198198
if (sessionMeta.compartmentInProgress) {
199+
sessionLog(
200+
sessionId,
201+
`compartment trigger: skipped — historian already in progress (usage=${usage.percentage.toFixed(1)}%)`,
202+
);
199203
return { shouldFire: false };
200204
}
201205

202206
const tailInfo = getUnsummarizedTailInfo(db, sessionId, triggerBudget);
203207
if (!tailInfo.hasNewRawHistory) {
208+
const lastCompartmentEnd = getLastCompartmentEndMessage(db, sessionId);
209+
const rawMessageCount = getRawSessionMessageCount(sessionId);
210+
const protectedTailStart = getProtectedTailStartOrdinal(sessionId);
211+
sessionLog(
212+
sessionId,
213+
`compartment trigger: skipped — no new raw history (usage=${usage.percentage.toFixed(1)}% nextStartOrdinal=${tailInfo.nextStartOrdinal} lastCompartmentEnd=${lastCompartmentEnd} rawMessageCount=${rawMessageCount} protectedTailStart=${protectedTailStart})`,
214+
);
204215
return { shouldFire: false };
205216
}
206217

@@ -267,6 +278,10 @@ export function checkCompartmentTrigger(
267278
executeThresholdPercentage,
268279
);
269280
if (usage.percentage < proactiveTriggerPercentage) {
281+
sessionLog(
282+
sessionId,
283+
`compartment trigger: not firing at ${usage.percentage.toFixed(1)}% — below proactive floor (${proactiveTriggerPercentage}%)`,
284+
);
270285
return { shouldFire: false };
271286
}
272287

0 commit comments

Comments
 (0)