Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .lore.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@

### Preference

<!-- lore:019e473a-2e06-7911-af1c-78191b4e3a4e -->
* **Always investigate cache warming system economics with specific cost/hit data before requesting fixes**: Cache warming system investigations: user arrives with concrete numerical evidence of poor ROI (e.g., '$65.89 spent, $4.43 saved'), specific session-level data (session IDs, turn counts, hit rates, P(returns) values), and identified problems. Trace full code path across cache-warmer.ts, cost-tracker.ts, pipeline.ts, and idle.ts. Ground responses in specific constants, formulas, and line numbers. Engage at the level of break-even thresholds, ROI guards, and survival probability math.
<!-- lore:019e44c8-e3b2-70c1-afb6-d3acf24c531a -->
* **Always fix cache memory leaks with TTL eviction, size cap, and scheduled pruning**: Cache memory leak fix pattern: (1) TTL check in \`.get()\` — delete and return undefined if expired; (2) LRU eviction in \`.set()\` — delete oldest key when \`store.size >= maxEntries\`; (3) \`setInterval(() => this.prune(), 60\_000)\` in constructor. Defaults: \`maxEntries = 10\_000\`, \`ttlMs = 300\_000\` (5 min). Note: \`prune()\` is NOT currently scheduled — the \`setInterval\` pattern is the prescribed fix, not existing behavior. Always use \`flock\` advisory locking instead of \`proper-lockfile\` — \`proper-lockfile@4.1.2\` fails in containerized environments where PID namespaces reset on restart, leaving stale locks. \`flock\` is automatically released on process exit. Session ground-truth: cache entries are never auto-evicted and \`prune()\` is never scheduled in current code — do not assert otherwise.

<!-- lore:019e4422-5b29-77a8-8956-488233ef16a4 -->
* **Always request critical code reviews with specific file paths, line numbers, and severity classifications**: Code review, investigation & workflow standards: (1) Reviews: exact file paths, line numbers, severity (C/M/L), root causes, concrete fixes. Check state-not-cleared, consume-once flags, circuit breaker bypass, concurrency edges. (2) Investigation: read actual source, trace full execution paths, enumerate 2-4 candidate explanations, report confirmed/falsified verdict with line numbers. Demand concrete metrics before accepting fixes. (3) PR discipline: critical self-review before merge, fix all criticals, CI green, amend+force-push. Resolve \`.lore.md\` rebase conflicts with \`--ours\`. After merge, pull main before follow-up work. (4) Planning: write plan file, wait for explicit approval, then execute. Pull from origin/main before any exploration or edits. (5) After bug fix: add tests (4-6 edge cases) in dedicated file referencing issue number. (6) Sentry IDs start with \`LOREAI-GATEWAY-\`. (7) Run lint, typecheck, full test suite before committing. (8) Present structured fix plan before implementation; wait for explicit approval. Never re-propose explicitly rejected approaches. Always include migration versioning context in schema change PRs.
Expand Down
14 changes: 8 additions & 6 deletions packages/gateway/src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3179,14 +3179,16 @@ async function handleConversationTurn(
: result.layer === 2 ? "aggressively compressed"
: result.layer >= 3 ? "emergency compressed" : "compressed";
ltmText += `\n\n[Context health: conversation history is ${layerDesc}. ` +
`Earlier details (file paths, error messages, decisions) are preserved in distilled ` +
`observations and searchable via the recall tool. Use recall proactively when referencing ` +
`details from earlier in the session.]`;
`Distilled observations above are lossy summaries — specific details ` +
`(exact error messages, rejected alternatives, file paths, numerical values) ` +
`are likely omitted. Use recall to verify any specific claim before answering ` +
`questions about what happened, what was considered, or what the exact values were.]`;
} else if (result.layer >= 1 && !ltmText) {
ltmText = `[Context health: conversation history is compressed. ` +
`Earlier details (file paths, error messages, decisions) are preserved in distilled ` +
`observations and searchable via the recall tool. Use recall proactively when referencing ` +
`details from earlier in the session.]`;
`Distilled observations above are lossy summaries — specific details ` +
`(exact error messages, rejected alternatives, file paths, numerical values) ` +
`are likely omitted. Use recall to verify any specific claim before answering ` +
`questions about what happened, what was considered, or what the exact values were.]`;
}

// --- 7d. Unsustainable conversation warning ---
Expand Down
Loading