Skip to content

Tighten people_map stoplist (Sprint 1 follow-up) - #124

Merged
besfeng23 merged 1 commit into
mainfrom
fix/pandora-people-stoplist
Jul 3, 2026
Merged

Tighten people_map stoplist (Sprint 1 follow-up)#124
besfeng23 merged 1 commit into
mainfrom
fix/pandora-people-stoplist

Conversation

@besfeng23

@besfeng23 besfeng23 commented Jul 3, 2026

Copy link
Copy Markdown
Owner

What

Roadmap Sprint 1 follow-up: remove residual common-noun false-positives from people_map that the initial stoplist (pronouns/imperatives/openers) didn't catch — Character, Dogs, Phase, Payment, Reservation, Command/Resort Command, Pandora Memory, Add, etc. These showed up live in AU + real_life people_map after the Sprint 1 deploy.

Change — lib/services/memory-distillation-service.ts

  • Expanded PERSON_NAME_STOPWORDS with common domain nouns.
  • isLikelyPersonName now rejects a name if any token is a stopword (so multi-word phrases like Resort Command / Pandora Memory are no longer treated as people).
  • Alias canonicalization, event_id dedup, and payload caps are unchanged.

Tests — tests/unit/context-stabilization.test.ts (6/6)

Added a case proving the residual nouns are dropped while real names (Janine Tan, Mang Jun, Joven Del Rosario) still pass; existing dedup/alias/caps/slim tests still green.

Verification

  • typecheck ✅ · lint ✅ (0 errors) · stabilization suite 6/6 ✅ (full suite/build verified on combined main before deploy).

Scope / safety

  • Deterministic only. No embeddings / semantic retrieval / model classification / broad entity system. No AU↔real_life mixing. No gated features touched.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved person-name detection so common nouns and product terms are less likely to be mistaken for real names.
    • Reduced false positives in name extraction while preserving valid people mentions.
  • Tests

    • Added coverage for name extraction to verify common nouns are excluded and real names remain included.

Removes residual common-noun false-positives from people extraction
(Character, Dogs, Phase, Payment, Reservation, Command/Resort Command,
Pandora Memory, Add, ...) by expanding the stoplist and rejecting a name
if ANY token is a known non-name word (so multi-word phrases like
"Resort Command" no longer register as people).

- Keeps alias canonicalization, event_id dedup, and payload caps unchanged.
- Real names (Janine Tan, Mang Jun, Joven Del Rosario) still pass.
- Test proves nouns dropped, names kept, aliases/dedup/caps intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
memory Ready Ready Preview, Comment Jul 3, 2026 3:19pm

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The person-name detection heuristic in the memory distillation service was updated: the stopword set was expanded with additional domain nouns, and the filtering logic now rejects a candidate if any token matches a stopword, rather than only the first token. A corresponding unit test was added.

Changes

Person Name Detection Heuristic

Layer / File(s) Summary
Stopword expansion and any-token filtering
lib/services/memory-distillation-service.ts
Expanded PERSON_NAME_STOPWORDS with additional domain nouns and changed isLikelyPersonName to reject candidates when any token matches a stopword, instead of only the first token.
Test coverage for false-positive filtering
tests/unit/context-stabilization.test.ts
Added a test verifying extractPeopleMentions excludes residual common-noun false positives while retaining real person names.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description does not follow the repository template and omits the required checklist section about env vars and secrets. Replace the current description with the required checklist template and answer each env var and secret question explicitly.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: tightening the people_map stoplist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pandora-people-stoplist

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
lib/services/memory-distillation-service.ts (2)

50-64: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Stopword list expansion looks reasonable; minor duplicate entry.

"core" is already present at line 56 and re-added at line 63. Harmless since it's a Set, but worth a quick cleanup pass.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/services/memory-distillation-service.ts` around lines 50 - 64, Clean up
the PERSON_NAME_STOPWORDS list in memory-distillation-service.ts by removing the
duplicate "core" entry from the set initializer. The issue is harmless because
it uses a Set, but the duplicate should be deleted to keep the stopword list
tidy and avoid confusion when reviewing or extending the constants.

68-74: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Any-token stopword check confirmed correct and consistent with regex matching behavior.

Verified the greedy regex \b[A-Z][a-z]+(?:\s+[A-Z][a-z]+){0,2}\b will already capture leading stopwords like "The" as part of multi-word matches (e.g. "The Character"), so most of the new test's multi-word junk cases (Resort Command, Pandora Memory) were already excluded by the pre-existing first-token check once their leading word ("resort", "pandora") was in the stopword set. The any-token change genuinely matters for cases where the stopword is not the first token (e.g. a capitalized phrase like "John Payment"), which none of the current tests exercise. Logic itself looks correct.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/services/memory-distillation-service.ts` around lines 68 - 74, The
any-token stopword logic in isLikelyPersonName is already correct, so no code
change is needed here; keep the existing tokens.some(...) check and ensure any
future tests cover cases where a stopword appears after the first token (for
example, capitalized phrases like “John Payment”) to preserve the intended
behavior.
tests/unit/context-stabilization.test.ts (1)

24-35: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test doesn't isolate the new "any-token" behavior.

Traced through the regex against the sample sentence: every multi-word junk phrase in this test ("Resort Command", "Pandora Memory") has a stopword as its first token (resort, pandora), so these cases would already be filtered out by the old first-token-only check once the stopword list was expanded — they don't actually exercise the new tokens.some(...) logic. Similarly, "Add" was already a stopword before this PR (line 53), so it isn't new coverage either.

Consider adding a case where the stopword appears only in a non-first position (e.g. a phrase like "John Command" or "Grace Payment"), which is the actual behavior this diff changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/context-stabilization.test.ts` around lines 24 - 35, The current
test in extractPeopleMentions does not isolate the new any-token filtering path
because the multi-word junk cases are already caught by first-token stopwords
and “Add” is preexisting coverage. Update the context-stabilization test data in
context-stabilization.test.ts to include at least one phrase where the stopword
appears in a non-first position, using the extractPeopleMentions and ev helpers,
so the assertion directly exercises the new tokens.some(...) behavior while
still verifying real names are preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lib/services/memory-distillation-service.ts`:
- Around line 50-64: Clean up the PERSON_NAME_STOPWORDS list in
memory-distillation-service.ts by removing the duplicate "core" entry from the
set initializer. The issue is harmless because it uses a Set, but the duplicate
should be deleted to keep the stopword list tidy and avoid confusion when
reviewing or extending the constants.
- Around line 68-74: The any-token stopword logic in isLikelyPersonName is
already correct, so no code change is needed here; keep the existing
tokens.some(...) check and ensure any future tests cover cases where a stopword
appears after the first token (for example, capitalized phrases like “John
Payment”) to preserve the intended behavior.

In `@tests/unit/context-stabilization.test.ts`:
- Around line 24-35: The current test in extractPeopleMentions does not isolate
the new any-token filtering path because the multi-word junk cases are already
caught by first-token stopwords and “Add” is preexisting coverage. Update the
context-stabilization test data in context-stabilization.test.ts to include at
least one phrase where the stopword appears in a non-first position, using the
extractPeopleMentions and ev helpers, so the assertion directly exercises the
new tokens.some(...) behavior while still verifying real names are preserved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9cf4a076-cf11-4aca-ad9c-9097d16370a5

📥 Commits

Reviewing files that changed from the base of the PR and between b61c963 and a4713ef.

📒 Files selected for processing (2)
  • lib/services/memory-distillation-service.ts
  • tests/unit/context-stabilization.test.ts

@besfeng23
besfeng23 merged commit 34c3a71 into main Jul 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants