Skip to content
Open
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
28 changes: 11 additions & 17 deletions dist/src/smart-extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { buildExtractionPrompt, buildDedupPrompt, buildMergePrompt, } from "./extraction-prompts.js";
import { AdmissionController, } from "./admission-control.js";
import { ALWAYS_MERGE_CATEGORIES, MERGE_SUPPORTED_CATEGORIES, TEMPORAL_VERSIONED_CATEGORIES, normalizeCategory, } from "./memory-categories.js";
import { ALWAYS_MERGE_CATEGORIES, getStorageCategoryForMemoryCategory, MERGE_SUPPORTED_CATEGORIES, TEMPORAL_VERSIONED_CATEGORIES, normalizeCategory, } from "./memory-categories.js";
import { isMetaFrustrationNoise, isNoise } from "./noise-filter.js";
import { appendRelation, buildSmartMetadata, deriveFactKey, parseSmartMetadata, stringifySmartMetadata, parseSupportInfo, updateSupportStats, } from "./smart-metadata.js";
import { isUserMdExclusiveMemory, } from "./workspace-boundary.js";
Expand Down Expand Up @@ -1149,23 +1149,17 @@ export class SmartExtractor {
/**
* Map 6-category to existing 5-category store type for backward compatibility.
*/
/**
* Map a smart register onto its legacy storage category, delegating to the
* shared SMART_TO_STORAGE_CATEGORY constant (memory-categories) so the
* mapping has a single source of truth. Note: "reflection" is a legacy
* storage category minted only by the reflection writer and is deliberately
* absent from this map; smart extraction never produces reflection rows.
* The "other" fallback covers non-union values arriving from untyped
* callers at runtime, matching the old switch's default arm.
*/
mapToStoreCategory(category) {
switch (category) {
case "profile":
return "fact";
case "preferences":
return "preference";
case "entities":
return "entity";
case "events":
return "decision";
case "cases":
return "fact";
case "patterns":
return "other";
default:
return "other";
}
return getStorageCategoryForMemoryCategory(category) ?? "other";
}
/**
* Get default importance score by category.
Expand Down
10 changes: 8 additions & 2 deletions src/memory-categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export const TOOL_MEMORY_CATEGORIES = [
export type MemoryCategory = (typeof MEMORY_CATEGORIES)[number];
export type LegacyMemoryCategory = (typeof LEGACY_MEMORY_CATEGORIES)[number];

const SMART_TO_STORAGE_CATEGORY: Record<MemoryCategory, LegacyMemoryCategory> = {
/**
* Storage categories that smart registers map onto. "reflection" is minted
* only by the reflection writer and is deliberately absent from this map.
*/
export type SmartStorageCategory = Exclude<LegacyMemoryCategory, "reflection">;

const SMART_TO_STORAGE_CATEGORY: Record<MemoryCategory, SmartStorageCategory> = {
profile: "fact",
preferences: "preference",
entities: "entity",
Expand Down Expand Up @@ -172,7 +178,7 @@ export function resolveCategoryFilterCandidates(requestedCategory: string): stri

export function getStorageCategoryForMemoryCategory(
category: MemoryCategory,
): LegacyMemoryCategory {
): SmartStorageCategory {
return SMART_TO_STORAGE_CATEGORY[category];
}

Expand Down
27 changes: 11 additions & 16 deletions src/smart-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
type ExtractionStats,
type MemoryCategory,
ALWAYS_MERGE_CATEGORIES,
getStorageCategoryForMemoryCategory,
MERGE_SUPPORTED_CATEGORIES,
MEMORY_CATEGORIES,
TEMPORAL_VERSIONED_CATEGORIES,
Expand Down Expand Up @@ -1759,25 +1760,19 @@ export class SmartExtractor {
/**
* Map 6-category to existing 5-category store type for backward compatibility.
*/
/**
* Map a smart register onto its legacy storage category, delegating to the
* shared SMART_TO_STORAGE_CATEGORY constant (memory-categories) so the
* mapping has a single source of truth. Note: "reflection" is a legacy
* storage category minted only by the reflection writer and is deliberately
* absent from this map; smart extraction never produces reflection rows.
* The "other" fallback covers non-union values arriving from untyped
* callers at runtime, matching the old switch's default arm.
*/
private mapToStoreCategory(
category: MemoryCategory,
): "preference" | "fact" | "decision" | "entity" | "other" {
switch (category) {
case "profile":
return "fact";
case "preferences":
return "preference";
case "entities":
return "entity";
case "events":
return "decision";
case "cases":
return "fact";
case "patterns":
return "other";
default:
return "other";
}
return getStorageCategoryForMemoryCategory(category) ?? "other";
}

/**
Expand Down
Loading