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
9 changes: 8 additions & 1 deletion lib/services/memory-distillation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,21 @@ const PERSON_NAME_STOPWORDS = new Set<string>([
"before", "during", "after", "every", "each", "all", "any", "some", "main", "core", "both", "new", "old",
"rule", "rules", "story", "scene", "scenes", "style", "canon", "user", "users", "taglish", "status",
"pandora", "chatgpt", "memory",
// Common domain nouns that are never a person's name (roadmap Sprint 1 follow-up).
"character", "characters", "dog", "dogs", "phase", "phases", "payment", "payments", "reservation", "reservations",
"command", "resort", "booking", "bookings", "admin", "project", "projects", "website", "audit", "entry", "entries",
"plan", "plans", "system", "systems", "engine", "profile", "profiles", "schema", "migration", "repo", "github",
"vercel", "supabase", "core", "master", "daily", "context", "pack", "packs", "event", "events", "loop", "loops",
]);

type PersonEntry = { name: string; event_ids: string[]; notes: string[] };

function isLikelyPersonName(name: string): boolean {
const tokens = name.split(/\s+/).filter(Boolean);
if (tokens.length === 0) return false;
if (PERSON_NAME_STOPWORDS.has(tokens[0].toLowerCase())) return false;
// Reject if ANY token is a known non-name word (pronoun/imperative/opener/common domain noun),
// so multi-word phrases like "Resort Command" or "Pandora Memory" are not treated as people.
if (tokens.some((token) => PERSON_NAME_STOPWORDS.has(token.toLowerCase()))) return false;
if (tokens.length === 1) return tokens[0].length >= 3;
return true;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/context-stabilization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ describe("Sprint 1 — stabilize output (people_map + payload)", () => {
}
});

it("drops residual common-noun false positives (Character/Dogs/Phase/Payment/...) but keeps real names", () => {
const events = [
ev("e1", "Janine Tan met Mang Jun. The Character and Dogs appear. Phase two, Payment and Reservation are due. Resort Command and Pandora Memory are systems. Add this. Joven Del Rosario noted it."),
];
const names = extractPeopleMentions(events).map((p) => p.name);
expect(names).toContain("Janine Tan");
expect(names).toContain("Mang Jun");
expect(names.some((n) => n.startsWith("Joven"))).toBe(true);
for (const junk of ["Character", "Dogs", "Phase", "Payment", "Reservation", "Command", "Resort Command", "Pandora Memory", "Add"]) {
expect(names).not.toContain(junk);
}
});

it("counts each event once per person (no per-occurrence id duplication)", () => {
const events = [ev("e1", "Janine Tan. Janine Tan. Janine Tan smiled at Janine Tan.")];
const [person] = extractPeopleMentions(events);
Expand Down
Loading