From bf868f7d81282dbeb62a6ebbfc60b12eb0459b42 Mon Sep 17 00:00:00 2001 From: Isaiah Tennell Date: Tue, 3 Nov 2026 20:42:49 -0600 Subject: [PATCH 1/5] Partner practice news passes: positive business clauses after she/he/they Fixed business phrases (opened/moved/hiring + practice, on vacation, out until, asked for my brochure/NPI, has openings, takes a payer, presenting at, co-lead a workshop, mentioned a new group/IOP, sees a lot of referrals) followed only by time and place words. Field words count only in the sees-referrals frame. lunch-and-learn and IOP are business words. 22 smuggles as tests. Co-Authored-By: Claude Opus 5.5 --- docs/BUILD_LOG.md | 1 + lib/aeon/guard.ts | 55 +++++++++++++++++++++++-- lib/aeon/identity-filter.ts | 2 +- tests/fixtures/partner-first-names.ts | 46 +++++++++++++++++++++ tests/guard-partner-first-names.test.ts | 6 +-- 5 files changed, 102 insertions(+), 8 deletions(-) diff --git a/docs/BUILD_LOG.md b/docs/BUILD_LOG.md index 4899dbd..e452b72 100644 --- a/docs/BUILD_LOG.md +++ b/docs/BUILD_LOG.md @@ -286,3 +286,4 @@ PTSD") is read joined; "identifying" now needs two details (age, job, place) or - 2026-11-03: Partners by first name. "Set a meeting with Maria, Pamela and Birinder" was refused as a stranger's name: the name-finder read "Maria, Pamela" as one name (and cut "Birinder" to "Biri"), and only whole board names or a referral word let a partner through. Now each name is matched against the people on her board first: a first name or surname (any case, credentials out) on exactly one card is that partner; on two or more cards Aeon asks "Which Maria do you mean: ...?"; on none it is refused as before. Client cues, health details about a person and unknown names still refuse. The meeting tool also finds a card by first name, and still refuses Not a fit, do-not-contact and private cards in plain words. - 2026-11-03: Partners by first name, review fixes. A partner's first name now passes only in a referral sentence (a coffee, lunch, meeting, call, email, letter or intro, a command to her, or "Dr." before it), never just because the sentence lacks client words: one partner named John no longer clears "John is grieving his father". A first name next to her own life details (a claim, a no-show, a job, an age, a divorce), a next sentence leaning on it ("Her son was arrested."), the same name with a diagnosis later in the message, and a lowercase partner name in a client sentence all refuse. 81 review leaks added as must-refuse tests. - 2026-11-03: Partners by first name, round 2. Once a partner is named by first name or surname alone, the rest of the sentence and the next one may say only business things: her/his/their plus a business word (practice, waitlist, referrals, fees...), she/he/they plus a business phrase (said she'd send referrals, has openings, sees adults), about/re:/regarding plus a business word, and no bare number. "lunch with David, he's on probation" and "call Pamela about her FMLA paperwork" now refuse; 13 new smuggles added as tests. +- 2026-11-03: Partner practice news. The everyday things she says about a partner now pass after she/he/they: opened or moved her practice, hiring a new associate, on vacation or out until a date, asked for my brochure or NPI, has openings, takes a payer, presenting at a conference, co-leading a workshop, mentioned a new group or IOP, and "sees a lot of perinatal anxiety referrals". Each is a fixed business phrase followed only by time and place words, so "he's on vacation in rehab" and "she moved her practice because of her breakdown" still refuse. 22 new smuggles added as tests. diff --git a/lib/aeon/guard.ts b/lib/aeon/guard.ts index 34974cf..ebefe51 100644 --- a/lib/aeon/guard.ts +++ b/lib/aeon/guard.ts @@ -269,10 +269,11 @@ const BUSINESS_NOUN = "openings?|fees?|rates?|schedule|calendar|e-?mail|emails|number|phone|website|site|specialty|specialties|specialization|focus|niche|card|letters?|flyer|" + "brochures?|talk|lunch|coffee|meeting|meetings|call|intro|introduction|partnership|collaboration|workshop|event|events|program|programs|services|" + "front\\s+desk|desk|address|fax|hours|location|offices|department|unit|coordinator|manager|receptionist|scheduler|process|forms?|network|panel|panels|" + - "insurance\\s+panels?|board|newsletter|presentation|training|book|podcast|blog|outreach|contact|info|information|details|new\\s+clients|openings"; + "insurance\\s+panels?|board|newsletter|presentation|training|book|podcast|blog|outreach|contact|info|information|details|new\\s+clients|openings|" + + "IOP|PHP|lunch-and-learn|lunch-and-learns|associate|associates|brochure|fee\\s+sheet|NPI|sliding\\s+scale|EHR|conference|webinar"; const BUSINESS_NOUN_RE = new RegExp(`^(?:${BUSINESS_NOUN})$`, "i"); /** Words that may come before a business noun ("her new practice", "his clinic's waitlist", "their intake process"). */ -const MODIFIER = /^(?:new|own|main|other|current|private|group|intake|referral|front|clinic|practice|office|team|lunch|quick|short|palliative|oncology|hospice|genetic|counseling|care|cancer|support|weekly|monthly|next|last|first|upcoming|free)$/i; +const MODIFIER = /^(?:new|second|own|main|DBT|CBT|EMDR|ACT|teen|adolescent|adult|child|couples|family|parenting|grief|perinatal|trauma|skills|process|virtual|telehealth|evening|weekend|solo|other|current|private|group|intake|referral|front|clinic|practice|office|team|lunch|quick|short|palliative|oncology|hospice|genetic|counseling|care|cancer|support|weekly|monthly|next|last|first|upcoming|free)$/i; /** One to three words, read as a business noun phrase ("clinic's waitlist", "palliative care referrals"). */ function businessPhrase(words: string[]): boolean { @@ -310,6 +311,50 @@ const BUSINESS_CLAUSE = new RegExp( "u", ); +// News about a partner's practice, read as a whole clause up to its end (a comma, a stop, "and +// she..."): the business phrase, then only time and place words ("next week", "in January", "to +// Evanston", "on Thursdays"). Anything else after it ("on vacation in rehab", "because of her +// breakdown") leaves the clause unread, so it refuses. A POSITIVE list, nothing else. +const MONTH = "January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec"; +const WEEKDAY = "Mondays?|Tuesdays?|Wednesdays?|Thursdays?|Fridays?|Saturdays?|Sundays?|weekends?|weekdays?|mornings?|afternoons?|evenings?"; +const NOT_A_PLACE = "(?!(?:Rehab|Detox|Jail|Prison|Hospital|ICU|ER|Court|Treatment|Recovery)\\b)"; +const PAYER = "BCBS|BCBSIL|Blue\\s+Cross(?:\\s+Blue\\s+Shield)?|Aetna|Cigna|United(?:healthcare)?|UHC|Medicaid|Medicare|Tricare|Humana|Optum|Magellan|Meridian|CountyCare|most\\s+insurance|insurance"; +const FIELD = + "perinatal|postpartum|anxiety|depression|grief|bereavement|trauma|oncology|cancer|cancer-related|adolescent|teen|child|couples|family|LGBTQ\\+?|queer|trans|" + + "substance|substance-use|ADHD|OCD|eating|disorder|insurance|Medicaid|Medicare|older|adult|college|student|veteran|chronic|illness|hospice|palliative|end-of-life|new|self-pay"; +const ASKED_FOR = "brochure|fee\\s+sheet|NPI|availability|card|business\\s+card|rates|fees|sliding\\s+scale|flyer|website|info|CV|bio|intake\\s+forms?"; +const PRACTICE_NEWS_CLAUSE = [ + `(?:opened|opening|opens|moved|moving|moves|hiring|hires|hired|starting|started|starts|leaving|left|leaves|switching|switched|expanding|expanded|growing|closing|closed|relocating|relocated)\\s+(?:(?:her|his|their|a|an|the)\\s+)?(?:(?:new|second|third|own|group|private|solo|teen|adolescent|adult|family|couples|weekend|evening|virtual|telehealth|DBT|CBT)\\s+){0,2}(?:practice|group|office|program|clinic|location|IOP|PHP|waitlist)`, + `(?:hiring|hires|hired|adding|added)\\s+(?:a|an|another|one|two)\\s+(?:new\\s+)?(?:associates?|therapists?|clinicians?|counselors?|interns?|billers?|receptionists?)`, + `(?:switching|switched|moving|moved)\\s+to\\s+(?:an?\\s+)?(?:new\\s+)?(?:EHR|telehealth|[A-Z][\\w-]+)`, + `on\\s+vacation`, + `out\\s+of\\s+(?:the\\s+)?office`, + `(?:out|away|off)(?=\\s+(?:until|through|till)\\b)`, + `asked\\s+(?:for|about)\\s+my\\s+(?:${ASKED_FOR})(?:\\s*(?:,|and)\\s*(?:my\\s+)?(?:${ASKED_FOR}))*`, + `(?:has|have|got|had)\\s+(?:some\\s+|a\\s+few\\s+|new\\s+|two\\s+|three\\s+)?(?:openings|availability|room|space|slots)`, + `(?:takes|accepts|taking|accepting|take|accept)\\s+(?:${PAYER})`, + `(?:presenting|presents|present|speaking|speaks|speak)\\s+at\\s+(?:the\\s+|a\\s+|an\\s+)?(?:(?:[A-Z][\\w-]*|counseling|therapy|clinical|regional|state|annual|national|local|spring|fall)\\s+){0,4}(?:conference|workshop|training|summit|meeting|event|grand\\s+rounds|webinar|lunch-and-learn)`, + `(?:(?:wants?|wanted|plans?|planning|hopes?|hoping)\\s+to\\s+)?(?:co-?lead|co-?leads|co-?leading|lead|leads|leading|host|hosts|hosting|run|runs|running)\\s+(?:a|an|the)\\s+(?:new\\s+)?(?:workshop|training|webinar|lunch-and-learn|consultation\\s+group)`, + `mentioned\\s+(?:a|an|the|her|his|their)\\s+(?:new\\s+)?(?:group|IOP|PHP|program|workshop|office|location|practice|associate|opening|training)`, + `(?:sees|gets|receives|see|get)\\s+(?:a\\s+lot\\s+of|lots\\s+of|many|mostly|plenty\\s+of)\\s+(?:(?:${FIELD})\\s+){1,3}referrals`, +].join("|"); +const PRACTICE_NEWS_TAIL = + `(?:\\s+(?:next|this|last)\\s+(?:week|month|year|weekend|spring|summer|fall|winter)|\\s+(?:in|on|until|through|till|by|from|after|before|starting)\\s+(?:the\\s+)?(?:${MONTH}|${WEEKDAY}|spring|summer|fall|winter|the\\s+\\d{1,2}(?:st|nd|rd|th)?|\\d{1,2}\\/\\d{1,2})(?:\\s+\\d{1,2}(?:st|nd|rd|th)?)?|` + + `\\s+(?:to|in)\\s+${NOT_A_PLACE}[A-Z][\\w-]+(?:\\s+${NOT_A_PLACE}[A-Z][\\w-]+){0,2}|\\s+on\\s+(?:${WEEKDAY}|Zoom)|\\s+(?:soon|again|too|now|already|this\\s+week))*`; +const PRACTICE_NEWS = new RegExp( + `^(?:['’](?:s|d|ll|re|ve)\\b|\\s+(?:is|are|was|were|will|would|can|could|might|may|should))?(?:\\s+(?:just|also|recently|now|still|finally|really|soon))*\\s+(?:${PRACTICE_NEWS_CLAUSE})${PRACTICE_NEWS_TAIL}\\s*(?:[.,;!?]|$|\\s+and\\s+(?=(?:she|he|they)\\b))`, + "u", +); +// Field words name the referrals a partner sees, never a person's condition, only in this frame. +const SEES_REFERRALS = new RegExp( + `\\b(?:she|he|they)\\s+(?:sees|gets|receives|see|get)\\s+(?:a\\s+lot\\s+of|lots\\s+of|many|mostly|plenty\\s+of)\\s+(?:(?:${FIELD})\\s+){1,3}referrals\\b(?=\\s*(?:[.,;!?]|$))`, + "giu", +); +/** The sentence with a partner's "sees a lot of perinatal anxiety referrals" read as plain referral talk. */ +export function withoutReferralFields(s: string): string { + return s.replace(SEES_REFERRALS, (m) => m.split(/\s+/)[0] + " sends referrals"); +} + /** True when everything said about a person in this sentence is practice business. */ export function businessOnly(s: string): boolean { if (/,\s*\d{1,3}\b/.test(s)) return false; @@ -323,7 +368,8 @@ export function businessOnly(s: string): boolean { if (!businessPhrase(wordsAfter(s, (m.index ?? 0) + m[0].length))) return false; } for (const m of s.matchAll(/\b(?:she|he|they)\b/giu)) { - if (!BUSINESS_CLAUSE.test(s.slice((m.index ?? 0) + m[0].length))) return false; + const rest = s.slice((m.index ?? 0) + m[0].length); + if (!BUSINESS_CLAUSE.test(rest) && !PRACTICE_NEWS.test(rest)) return false; } for (const m of s.matchAll(/\b(?:about|regarding|re:?|to\s+discuss|discuss(?:ing)?|on\s+the)\s+/giu)) { const ws = wordsAfter(s, (m.index ?? 0) + m[0].length, 5); @@ -335,8 +381,9 @@ export function businessOnly(s: string): boolean { return true; } -function partnerSentenceClean(s: string, said: string): boolean { +function partnerSentenceClean(sentence: string, said: string): boolean { const who = escape(said); + const s = withoutReferralFields(sentence); return ( !MY_CLIENT.test(s) && !/\b(?:client|patient)\b/i.test(s) && diff --git a/lib/aeon/identity-filter.ts b/lib/aeon/identity-filter.ts index 34c020e..6ff2b2a 100644 --- a/lib/aeon/identity-filter.ts +++ b/lib/aeon/identity-filter.ts @@ -339,7 +339,7 @@ export function ownContext(sentence: string): boolean { // A sentence where a provider on her board belongs: their card, a letter, // outreach, their office, specialty or NPI. Only here is a board name directory data. const REFERRAL_CONTEXT = - /\b(cards?|board|letters?|referr\w*|refers?|NPI|NPPES|outreach|practice|office|address|speciali[sz]\w*|specialt\w*|accepting|e-?mail|phone|fax|follow[- ]?ups?|call log|contact\w*|providers?|directory|status|colleagues?|network|introduc\w*|reach(?:ed)?\s+out|coffees?|lunch(?:es)?|lunch\s+talks?|meet|meetings?|intros?|(?:a|the|phone|zoom|quick|intro|video)\s+calls?|calls?\s+with|(?:plan|set|book|schedule)\s+(?:up\s+)?(?:a\s+|an\s+|some\s+)?(?:coffees?|lunch(?:es)?|meetings?|calls?|chats?|intros?|e-?mails?|letters?)|follow\s+up|confirm\w*|chat|stage|column|pipeline|do not contact|LCSW|LICSW|LCPC|LPC|LMFT|MD|PhD|PsyD|chaplains?|reverend|navigators?|genetic\s+counsel\w*|social\s+workers?|oncolog\w*|hospice|palliative|miles?\s+away|\d+(?:\.\d+)?\s*mi)\b/i; + /\b(cards?|board|letters?|referr\w*|refers?|NPI|NPPES|outreach|practice|office|address|speciali[sz]\w*|specialt\w*|accepting|e-?mail|phone|fax|follow[- ]?ups?|call log|contact\w*|providers?|directory|status|colleagues?|network|introduc\w*|reach(?:ed)?\s+out|lunch-and-learns?|IOPs?|coffees?|lunch(?:es)?|lunch\s+talks?|meet|meetings?|intros?|(?:a|the|phone|zoom|quick|intro|video)\s+calls?|calls?\s+with|(?:plan|set|book|schedule)\s+(?:up\s+)?(?:a\s+|an\s+|some\s+)?(?:coffees?|lunch(?:es)?|meetings?|calls?|chats?|intros?|e-?mails?|letters?)|follow\s+up|confirm\w*|chat|stage|column|pipeline|do not contact|LCSW|LICSW|LCPC|LPC|LMFT|MD|PhD|PsyD|chaplains?|reverend|navigators?|genetic\s+counsel\w*|social\s+workers?|oncolog\w*|hospice|palliative|miles?\s+away|\d+(?:\.\d+)?\s*mi)\b/i; // A professional's credential after a name ("Brittany Keiser, MS, CGC", "Renata // Ostrowski, RN", "Rev. Tobias Wren"). Case-sensitive, so "do" and "ms" as words don't count. export const PROFESSIONAL_CREDENTIAL = diff --git a/tests/fixtures/partner-first-names.ts b/tests/fixtures/partner-first-names.ts index ae014d2..a05e4f1 100644 --- a/tests/fixtures/partner-first-names.ts +++ b/tests/fixtures/partner-first-names.ts @@ -141,3 +141,49 @@ export const REVIEW_MUST_PASS: string[] = [ "email Jennifer about a lunch talk", "set up an intro call with Chris", ]; + +/** Round 3: the practice news she says about a partner (business clauses). Must pass. */ +export const ROUND3_MUST_PASS: string[] = [ + "follow up with Maria, she mentioned a new group", + "call John next month, he's on vacation next week", + "lunch with Pamela to hear about her new IOP", + "email Lisa, she moved her practice to Evanston", + "follow up with David, he's hiring a new associate", + "follow up with James, he's got openings on Thursdays", + "email Pamela, she asked for my brochure and NPI", + "coffee with Maria, she sees a lot of perinatal anxiety referrals", + "follow up with David about the lunch-and-learn", + "coffee with Sarah, she just opened a second office", + "call Birinder, he's starting a teen program in January", + "coffee with Amanda, she's leaving her group practice", + "lunch with Jennifer, she's presenting at the IL counseling conference", + "set a meeting with Robert, he asked about my sliding scale", + "email Jessica, she takes Medicaid", + "follow up with Emily, she's out until March", +]; + +/** Round 3: smuggles aimed at the business clauses, and the earlier ones they must not reopen. Must refuse. */ +export const ROUND3_MUST_REFUSE: string[] = [ + "email Lisa, she moved her practice because of her breakdown", + "call John, he's on vacation in rehab", + "follow up with David, he's hiring a lawyer for his custody case", + "coffee with Maria, she sees a lot of referrals for her own PTSD", + "coffee with Maria, she sees a lot of perinatal anxiety referrals for her own PTSD", + "follow up with James, he has openings since his divorce", + "follow up with James, he's got openings since his divorce", + "email Lisa, she's out until her surgery", + "follow up with Maria, she mentioned a new group for her eating disorder", + "call Kevin, he's starting a new program at the methadone clinic", + "follow up with David, he's leaving his practice after the DUI", + "coffee with Sarah, she's presenting at her custody hearing", + "follow up with John, he's switching his practice, he's 17", + "email Jennifer, she takes Medicaid and she's pregnant", + "call Chris, he's on vacation, he's been suicidal lately", + "coffee with Amanda, she sees a lot of grief referrals since her mom died", + "follow up with Maria, she co-leads a workshop and she was abused", + "email Pamela, she asked for my brochure because she's been suicidal lately", + "coffee with Sarah, she's 17", + "lunch with Emily, she just got out of the psych ward", + "follow up with Emily, she's out of the psych ward", + "call John, he's been suicidal lately", +]; diff --git a/tests/guard-partner-first-names.test.ts b/tests/guard-partner-first-names.test.ts index 79c83f3..1d33313 100644 --- a/tests/guard-partner-first-names.test.ts +++ b/tests/guard-partner-first-names.test.ts @@ -9,7 +9,7 @@ import { loadEnv } from "../lib/env"; loadEnv(); const { guard, partnerMatch, whichPartner, looksLikePerson, spokenName } = await import("../lib/aeon/guard"); const { withContext } = await import("../lib/referrals/ask-context"); -const { COMMON_BOARD, REVIEW_MUST_PASS, REVIEW_MUST_REFUSE, ROUND2_MUST_PASS, ROUND2_MUST_REFUSE } = await import("./fixtures/partner-first-names"); +const { COMMON_BOARD, REVIEW_MUST_PASS, REVIEW_MUST_REFUSE, ROUND2_MUST_PASS, ROUND2_MUST_REFUSE, ROUND3_MUST_PASS, ROUND3_MUST_REFUSE } = await import("./fixtures/partner-first-names"); const { DEMO_ALLOWED, MUST_REFUSE: ADVERSARIAL_REFUSE } = await import("./fixtures/guard-adversarial"); const BOARD = ["[Sample] Maria Halvorsen, MS", "[Sample] Pamela Serrano Vidal, MD", "[Sample] Birinder Malhi, MD", "[Sample] Juniper Row Family Medicine"]; @@ -135,7 +135,7 @@ describe("board partners by first name or surname", () => { // The PR #153 review: one partner named John must never clear "John is grieving his father". const common = { names: [...OWN, ...COMMON_BOARD], contacts: [], directory: COMMON_BOARD }; - it.each([...REVIEW_MUST_REFUSE, ...ROUND2_MUST_REFUSE])("review leak, still refused with common first names on the board: %s", async (m) => { + it.each([...REVIEW_MUST_REFUSE, ...ROUND2_MUST_REFUSE, ...ROUND3_MUST_REFUSE])("review leak, still refused with common first names on the board: %s", async (m) => { for (const text of [m, withContext(m, "Partners", PICKED)]) { const r = await guard(text, "message", common, ASK); expect(r.ok, text).toBe(false); @@ -143,7 +143,7 @@ describe("board partners by first name or surname", () => { } }, T); - it.each([...REVIEW_MUST_PASS, ...ROUND2_MUST_PASS, ...MUST_PASS])("review must-pass with common first names on the board: %s", async (m) => { + it.each([...REVIEW_MUST_PASS, ...ROUND2_MUST_PASS, ...ROUND3_MUST_PASS, ...MUST_PASS])("review must-pass with common first names on the board: %s", async (m) => { expect(await guard(m, "message", common, ASK), m).toEqual({ ok: true, text: m }); expect((await guard(withContext(m, "Partners", PICKED), "message", common, ASK)).ok, m).toBe(true); }, T); From cea4e9394d4416af091ba02484d3167e72e77f08 Mon Sep 17 00:00:00 2001 From: Isaiah Tennell Date: Tue, 3 Nov 2026 21:00:49 -0600 Subject: [PATCH 2/5] Business clause must end the sentence: no fragment after a comma or semicolon Co-Authored-By: Claude Opus 5.5 --- docs/BUILD_LOG.md | 1 + lib/aeon/guard.ts | 11 +++++++++-- tests/fixtures/partner-first-names.ts | 13 +++++++++++++ tests/guard-partner-first-names.test.ts | 6 +++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/docs/BUILD_LOG.md b/docs/BUILD_LOG.md index e452b72..6f464a6 100644 --- a/docs/BUILD_LOG.md +++ b/docs/BUILD_LOG.md @@ -287,3 +287,4 @@ PTSD") is read joined; "identifying" now needs two details (age, job, place) or - 2026-11-03: Partners by first name, review fixes. A partner's first name now passes only in a referral sentence (a coffee, lunch, meeting, call, email, letter or intro, a command to her, or "Dr." before it), never just because the sentence lacks client words: one partner named John no longer clears "John is grieving his father". A first name next to her own life details (a claim, a no-show, a job, an age, a divorce), a next sentence leaning on it ("Her son was arrested."), the same name with a diagnosis later in the message, and a lowercase partner name in a client sentence all refuse. 81 review leaks added as must-refuse tests. - 2026-11-03: Partners by first name, round 2. Once a partner is named by first name or surname alone, the rest of the sentence and the next one may say only business things: her/his/their plus a business word (practice, waitlist, referrals, fees...), she/he/they plus a business phrase (said she'd send referrals, has openings, sees adults), about/re:/regarding plus a business word, and no bare number. "lunch with David, he's on probation" and "call Pamela about her FMLA paperwork" now refuse; 13 new smuggles added as tests. - 2026-11-03: Partner practice news. The everyday things she says about a partner now pass after she/he/they: opened or moved her practice, hiring a new associate, on vacation or out until a date, asked for my brochure or NPI, has openings, takes a payer, presenting at a conference, co-leading a workshop, mentioned a new group or IOP, and "sees a lot of perinatal anxiety referrals". Each is a fixed business phrase followed only by time and place words, so "he's on vacation in rehab" and "she moved her practice because of her breakdown" still refuse. 22 new smuggles added as tests. +- 2026-11-03: Partner practice news, round 4. A business clause about a partner now has to end the sentence (or hand over with ", and she..."): "she's out until Monday, Mercy Hospital" refuses instead of reading the part after the comma as part of the clause. "he said his front desk lost my fax" passes. diff --git a/lib/aeon/guard.ts b/lib/aeon/guard.ts index ebefe51..44c47be 100644 --- a/lib/aeon/guard.ts +++ b/lib/aeon/guard.ts @@ -336,13 +336,14 @@ const PRACTICE_NEWS_CLAUSE = [ `(?:presenting|presents|present|speaking|speaks|speak)\\s+at\\s+(?:the\\s+|a\\s+|an\\s+)?(?:(?:[A-Z][\\w-]*|counseling|therapy|clinical|regional|state|annual|national|local|spring|fall)\\s+){0,4}(?:conference|workshop|training|summit|meeting|event|grand\\s+rounds|webinar|lunch-and-learn)`, `(?:(?:wants?|wanted|plans?|planning|hopes?|hoping)\\s+to\\s+)?(?:co-?lead|co-?leads|co-?leading|lead|leads|leading|host|hosts|hosting|run|runs|running)\\s+(?:a|an|the)\\s+(?:new\\s+)?(?:workshop|training|webinar|lunch-and-learn|consultation\\s+group)`, `mentioned\\s+(?:a|an|the|her|his|their)\\s+(?:new\\s+)?(?:group|IOP|PHP|program|workshop|office|location|practice|associate|opening|training)`, + `(?:said|says|mentioned)\\s+(?:that\\s+)?(?:her|his|their)\\s+(?:front\\s+desk|office|staff|team|scheduler|biller|receptionist|office\\s+manager)\\s+(?:lost|has|needs|got|never\\s+got|didn['’]t\\s+get|sent|missed|wants)\\s+my\\s+(?:fax|referral|letter|e-?mail|brochure|card|forms?|NPI|fee\\s+sheet)`, `(?:sees|gets|receives|see|get)\\s+(?:a\\s+lot\\s+of|lots\\s+of|many|mostly|plenty\\s+of)\\s+(?:(?:${FIELD})\\s+){1,3}referrals`, ].join("|"); const PRACTICE_NEWS_TAIL = `(?:\\s+(?:next|this|last)\\s+(?:week|month|year|weekend|spring|summer|fall|winter)|\\s+(?:in|on|until|through|till|by|from|after|before|starting)\\s+(?:the\\s+)?(?:${MONTH}|${WEEKDAY}|spring|summer|fall|winter|the\\s+\\d{1,2}(?:st|nd|rd|th)?|\\d{1,2}\\/\\d{1,2})(?:\\s+\\d{1,2}(?:st|nd|rd|th)?)?|` + `\\s+(?:to|in)\\s+${NOT_A_PLACE}[A-Z][\\w-]+(?:\\s+${NOT_A_PLACE}[A-Z][\\w-]+){0,2}|\\s+on\\s+(?:${WEEKDAY}|Zoom)|\\s+(?:soon|again|too|now|already|this\\s+week))*`; const PRACTICE_NEWS = new RegExp( - `^(?:['’](?:s|d|ll|re|ve)\\b|\\s+(?:is|are|was|were|will|would|can|could|might|may|should))?(?:\\s+(?:just|also|recently|now|still|finally|really|soon))*\\s+(?:${PRACTICE_NEWS_CLAUSE})${PRACTICE_NEWS_TAIL}\\s*(?:[.,;!?]|$|\\s+and\\s+(?=(?:she|he|they)\\b))`, + `^(?:['’](?:s|d|ll|re|ve)\\b|\\s+(?:is|are|was|were|will|would|can|could|might|may|should))?(?:\\s+(?:just|also|recently|now|still|finally|really|soon))*\\s+(?:${PRACTICE_NEWS_CLAUSE})${PRACTICE_NEWS_TAIL}(?=[.!?]?\\s*$|,?\\s+and\\s+(?:she|he|they)\\b)`, "u", ); // Field words name the referrals a partner sees, never a person's condition, only in this frame. @@ -369,7 +370,13 @@ export function businessOnly(s: string): boolean { } for (const m of s.matchAll(/\b(?:she|he|they)\b/giu)) { const rest = s.slice((m.index ?? 0) + m[0].length); - if (!BUSINESS_CLAUSE.test(rest) && !PRACTICE_NEWS.test(rest)) return false; + if (PRACTICE_NEWS.test(rest)) continue; + const clause = BUSINESS_CLAUSE.exec(rest); + if (!clause) return false; + // A business clause ends the sentence, or hands over with ", and she/he/they" (judged on its + // own above). Any other fragment after a comma or semicolon ("..., Mercy Hospital") refuses. + const after = rest.slice(clause[0].length).split(/,?\s+and\s+(?=(?:she|he|they)\b)/i)[0]; + if (/[,;:]/.test(after)) return false; } for (const m of s.matchAll(/\b(?:about|regarding|re:?|to\s+discuss|discuss(?:ing)?|on\s+the)\s+/giu)) { const ws = wordsAfter(s, (m.index ?? 0) + m[0].length, 5); diff --git a/tests/fixtures/partner-first-names.ts b/tests/fixtures/partner-first-names.ts index a05e4f1..3cf40c8 100644 --- a/tests/fixtures/partner-first-names.ts +++ b/tests/fixtures/partner-first-names.ts @@ -187,3 +187,16 @@ export const ROUND3_MUST_REFUSE: string[] = [ "follow up with Emily, she's out of the psych ward", "call John, he's been suicidal lately", ]; + +/** Round 4: a fragment after a comma or semicolon is never read as part of a business clause. Must refuse. */ +export const ROUND4_MUST_REFUSE: string[] = [ + "follow up with Emily, she's out until Monday, Mercy Hospital", + "follow up with Emily, she's out until Monday, Rush ICU", + "follow up with Emily, she's out until Monday; Northwestern psych", + "follow up with James, she has openings Thursdays, Mercy Hospital", + "follow up with James, he has openings Thursdays; Rush ICU", + "follow up with Emily, she's out on maternity leave until March", +]; + +/** Round 4: must pass. */ +export const ROUND4_MUST_PASS: string[] = ["call Michael, he said his front desk lost my fax"]; diff --git a/tests/guard-partner-first-names.test.ts b/tests/guard-partner-first-names.test.ts index 1d33313..557fe24 100644 --- a/tests/guard-partner-first-names.test.ts +++ b/tests/guard-partner-first-names.test.ts @@ -9,7 +9,7 @@ import { loadEnv } from "../lib/env"; loadEnv(); const { guard, partnerMatch, whichPartner, looksLikePerson, spokenName } = await import("../lib/aeon/guard"); const { withContext } = await import("../lib/referrals/ask-context"); -const { COMMON_BOARD, REVIEW_MUST_PASS, REVIEW_MUST_REFUSE, ROUND2_MUST_PASS, ROUND2_MUST_REFUSE, ROUND3_MUST_PASS, ROUND3_MUST_REFUSE } = await import("./fixtures/partner-first-names"); +const { COMMON_BOARD, REVIEW_MUST_PASS, REVIEW_MUST_REFUSE, ROUND2_MUST_PASS, ROUND2_MUST_REFUSE, ROUND3_MUST_PASS, ROUND3_MUST_REFUSE, ROUND4_MUST_PASS, ROUND4_MUST_REFUSE } = await import("./fixtures/partner-first-names"); const { DEMO_ALLOWED, MUST_REFUSE: ADVERSARIAL_REFUSE } = await import("./fixtures/guard-adversarial"); const BOARD = ["[Sample] Maria Halvorsen, MS", "[Sample] Pamela Serrano Vidal, MD", "[Sample] Birinder Malhi, MD", "[Sample] Juniper Row Family Medicine"]; @@ -135,7 +135,7 @@ describe("board partners by first name or surname", () => { // The PR #153 review: one partner named John must never clear "John is grieving his father". const common = { names: [...OWN, ...COMMON_BOARD], contacts: [], directory: COMMON_BOARD }; - it.each([...REVIEW_MUST_REFUSE, ...ROUND2_MUST_REFUSE, ...ROUND3_MUST_REFUSE])("review leak, still refused with common first names on the board: %s", async (m) => { + it.each([...REVIEW_MUST_REFUSE, ...ROUND2_MUST_REFUSE, ...ROUND3_MUST_REFUSE, ...ROUND4_MUST_REFUSE])("review leak, still refused with common first names on the board: %s", async (m) => { for (const text of [m, withContext(m, "Partners", PICKED)]) { const r = await guard(text, "message", common, ASK); expect(r.ok, text).toBe(false); @@ -143,7 +143,7 @@ describe("board partners by first name or surname", () => { } }, T); - it.each([...REVIEW_MUST_PASS, ...ROUND2_MUST_PASS, ...ROUND3_MUST_PASS, ...MUST_PASS])("review must-pass with common first names on the board: %s", async (m) => { + it.each([...REVIEW_MUST_PASS, ...ROUND2_MUST_PASS, ...ROUND3_MUST_PASS, ...ROUND4_MUST_PASS, ...MUST_PASS])("review must-pass with common first names on the board: %s", async (m) => { expect(await guard(m, "message", common, ASK), m).toEqual({ ok: true, text: m }); expect((await guard(withContext(m, "Partners", PICKED), "message", common, ASK)).ok, m).toBe(true); }, T); From e1d45f2867a33c9222cf08f06752ede3e4af9091 Mon Sep 17 00:00:00 2001 From: Isaiah Tennell Date: Tue, 3 Nov 2026 21:32:00 -0600 Subject: [PATCH 3/5] Guard: UUIDs never read as phone numbers; partner business rules only on her words Root cause of the CI flake: a random approval_id's hex digits matched the phone pattern (~0.5%), so plan_referral_meeting's full-rules tool result was withheld. normalizeForCheck reads UUIDs as [id]. businessOnly/PERSONAL_MATTER/next-sentence rules now run only at message and memory (herWords), not on code-built results. Co-Authored-By: Claude Opus 5.5 --- docs/BUILD_LOG.md | 1 + lib/aeon/guard.ts | 48 +++++++++++++++---------- tests/guard-partner-first-names.test.ts | 31 ++++++++++++++++ 3 files changed, 62 insertions(+), 18 deletions(-) diff --git a/docs/BUILD_LOG.md b/docs/BUILD_LOG.md index 6f464a6..fc7c7dd 100644 --- a/docs/BUILD_LOG.md +++ b/docs/BUILD_LOG.md @@ -288,3 +288,4 @@ PTSD") is read joined; "identifying" now needs two details (age, job, place) or - 2026-11-03: Partners by first name, round 2. Once a partner is named by first name or surname alone, the rest of the sentence and the next one may say only business things: her/his/their plus a business word (practice, waitlist, referrals, fees...), she/he/they plus a business phrase (said she'd send referrals, has openings, sees adults), about/re:/regarding plus a business word, and no bare number. "lunch with David, he's on probation" and "call Pamela about her FMLA paperwork" now refuse; 13 new smuggles added as tests. - 2026-11-03: Partner practice news. The everyday things she says about a partner now pass after she/he/they: opened or moved her practice, hiring a new associate, on vacation or out until a date, asked for my brochure or NPI, has openings, takes a payer, presenting at a conference, co-leading a workshop, mentioned a new group or IOP, and "sees a lot of perinatal anxiety referrals". Each is a fixed business phrase followed only by time and place words, so "he's on vacation in rehab" and "she moved her practice because of her breakdown" still refuse. 22 new smuggles added as tests. - 2026-11-03: Partner practice news, round 4. A business clause about a partner now has to end the sentence (or hand over with ", and she..."): "she's out until Monday, Mercy Hospital" refuses instead of reading the part after the comma as part of the clause. "he said his front desk lost my fax" passes. +- 2026-11-03: Fixed a rare false privacy block on Aeon's own meeting results: about 1 in 200 random approval ids has hex digits that read as a phone number ("...-e18592619355"), so the meeting tool's answer was held back now and then. Ids are now read as "[id]" by the privacy check. The business-only rules for partners named by first name also apply only to her own words (message, memory), never to results the code builds. diff --git a/lib/aeon/guard.ts b/lib/aeon/guard.ts index 44c47be..c257320 100644 --- a/lib/aeon/guard.ts +++ b/lib/aeon/guard.ts @@ -131,11 +131,17 @@ export type PersonVerdict = { verdict: "ok" } | { verdict: "blank" } | { verdict * Anyone else is a stranger: refused when the sentence looks like a client's * (a visit, a bill, a condition), otherwise blanked where blanking is allowed. */ -export function judgePerson(name: string, text: string, allow: Allowlist): PersonVerdict { +/** + * `herWords`: the text is hers (her chat message, or a memory). Only there do the + * business-only rules apply around a partner named by first name or surname (businessOnly, + * PERSONAL_MATTER, the next sentence). Tool results and replies the code builds itself + * ("Tue Aug 19, 9:00 am", "Maria Halvorsen, MS") are judged without them. + */ +export function judgePerson(name: string, text: string, allow: Allowlist, herWords = true): PersonVerdict { // "Mark Brittany Keiser as contacted": the name-finder can take the command // word as a first name. When the rest is a whole name on her list, judge that. const command = COMMAND_BEFORE_NAME.exec(name); - if (command && wholeOf(wordsOf(command[1]), allow.names)) return judgePerson(command[1], text, allow); + if (command && wholeOf(wordsOf(command[1]), allow.names)) return judgePerson(command[1], text, allow, herWords); const words = wordsOf(name); // Only titles or a sample label ("Rev.", "[Sample]"): no one is named. if (words.length === 0) return { verdict: "ok" }; @@ -161,7 +167,7 @@ export function judgePerson(name: string, text: string, allow: Allowlist): Perso // claim", "no-showed") or a next sentence leaning on it ("Plan lunch with Maria. Her son was arrested."). const partOnly = boardPart && !boardWhole; const after = at >= 0 && partOnly ? leaningNext(text, at) : null; - const personal = partOnly && (PERSONAL_MATTER.test(s) || !businessOnly(s) || (after !== null && !partnerSentenceClean(after, name))); + const personal = herWords && partOnly && (PERSONAL_MATTER.test(s) || !businessOnly(s) || (after !== null && !partnerSentenceClean(after, name))); if (clean && !personal && (boardWhole || boardPart) && (referralContext(s) || command || (boardPart && titled))) continue; if (at >= 0 && colleagueAt(text, at, name) && !condition) continue; // A partner's staff by first name ("Jen at the front desk handles it"), outside any client sentence. @@ -174,8 +180,8 @@ export function judgePerson(name: string, text: string, allow: Allowlist): Perso } /** A name that passes where it stands (see judgePerson). */ -export function isAllowedPerson(name: string, text: string, allow: Allowlist): boolean { - return judgePerson(name, text, allow).verdict === "ok"; +export function isAllowedPerson(name: string, text: string, allow: Allowlist, herWords = true): boolean { + return judgePerson(name, text, allow, herWords).verdict === "ok"; } // ---- partners named by first name or surname ------------------------------------ @@ -388,7 +394,7 @@ export function businessOnly(s: string): boolean { return true; } -function partnerSentenceClean(sentence: string, said: string): boolean { +function partnerSentenceClean(sentence: string, said: string, herWords = true): boolean { const who = escape(said); const s = withoutReferralFields(sentence); return ( @@ -398,8 +404,7 @@ function partnerSentenceClean(sentence: string, said: string): boolean { !mentionsDiagnosis(s) && !mentionsMedical(s) && !medicalAboutSomeone(s) && - !PERSONAL_MATTER.test(s) && - businessOnly(s) && + (!herWords || (!PERSONAL_MATTER.test(s) && businessOnly(s))) && !namedCondition(said, s) && !new RegExp(`(? !cards.some((c) => c.words.includes(t.base)) && !COMMON_AFTER_NAME.test(t.base))) return { kind: "none" }; const spoken = text.slice(group[0].at, group.at(-1)!.end); const sent = sentenceAt(text, group[0].at); - if (!partnerSentenceClean(sent, spoken)) return { kind: "none" }; + if (!partnerSentenceClean(sent, spoken, herWords)) return { kind: "none" }; const after = leaningNext(text, group[0].at); - if (after && !partnerSentenceClean(after, spoken)) return { kind: "none" }; + if (herWords && after && !partnerSentenceClean(after, spoken)) return { kind: "none" }; // The positive gate stays: a referral sentence, a command to her, or "Dr." before the name. // A first name never clears a sentence just because it lacks client words. const titledHere = TITLE_BEFORE.test(text.slice(Math.max(0, group[0].at - 8), group[0].at)); @@ -550,7 +555,7 @@ function joinSpacedLetters(text: string): string { * name. Used for checking only; what is saved is unchanged. */ export function normalizeForCheck(text: string): string { - return foldTypos(joinSpacedLetters(foldLookalikes(text.normalize("NFKD").replace(/[\p{M}\p{Cf}]/gu, "").normalize("NFKC")))); + return foldTypos(joinSpacedLetters(foldLookalikes(text.replace(UUID_ANYWHERE, "[id]").normalize("NFKD").replace(/[\p{M}\p{Cf}]/gu, "").normalize("NFKC")))); } // Digits and symbols written for letters ("cl1ent S4rah K1ein", "p@tient", @@ -725,9 +730,16 @@ function joinBrokenLines(text: string): string { return text.replace(/([^.!?:;\s])[ \t]*\n+[ \t]*(?!(?:[-*•]|\d+[.)])\s)/g, "$1 "); } +// A UUID (an approval or card id the code puts in a tool result) is never a phone or record +// number, but its hex digits ("...-e18592619355") read as a phone about 1 time in 200: the +// checks read "[id]" in its place (normalizeForCheck). +const UUID_ANYWHERE = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi; + async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: GuardOptions): Promise { const plain = normalizeForCheck(text); const light = at === "tool_result" && !opts.fullRules; + // Her own words (her message, a memory) get the business-only rules around a partner's first name. + const herWords = at === "message" || at === "memory"; const rules = light ? checkIdentity(plain, list, TOOL_RESULT_RULES) : checkIdentity(plain, list); if (!rules.ok) return { ok: false, kind: rules.kind }; const detail = light ? personalDetail(plain, list) : null; @@ -768,7 +780,7 @@ async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: Gu } // A partner's first name or surname written in lowercase, which the name-finder can miss // ("maria no-showed again"), in a sentence about someone's own life or visits: refused. - if (at === "message" || at === "memory") { + if (herWords) { const cards = partnerCards(list); for (const t of tokensOf(plain)) { if (t.capital || !cards.some((c) => c.words.includes(t.base))) continue; @@ -781,7 +793,7 @@ async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: Gu // a name on two or more cards is asked about at her message, judged as before elsewhere. let ambiguous: { said: string; choices: string[] } | null = null; const asPartner = (n: string): boolean => { - const p = partnerMatch(n, plain, list); + const p = partnerMatch(n, plain, list, herWords); if (p.kind === "partners") return true; if (p.kind === "ambiguous" && at === "message" && opts.askWhichPartner) { ambiguous ??= { said: p.said, choices: p.choices }; @@ -791,9 +803,9 @@ async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: Gu }; for (const n of names.filter(isNameLike)) { if (asPartner(n)) continue; - const v = judgePerson(n, plain, list); + const v = judgePerson(n, plain, list, herWords); if (v.verdict === "refuse") return { ok: false, kind: v.kind }; - const w = joined === plain ? v : judgePerson(n, joined, list); + const w = joined === plain ? v : judgePerson(n, joined, list, herWords); if (w.verdict === "refuse") return { ok: false, kind: w.kind }; if (v.verdict === "blank" || w.verdict === "blank") strangers.push(n); } @@ -809,7 +821,7 @@ async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: Gu const capital = asWritten.split(/\s+/).filter((w) => /^\p{Lu}/u.test(w)); if (capital.length > 0 && capital.length < asWritten.split(/\s+/).length && partOf(wordsOf(capital.join(" ")), list.names)) continue; if (asPartner(asWritten)) continue; - const v = judgePerson(asWritten, plain, list); + const v = judgePerson(asWritten, plain, list, herWords); if (v.verdict === "refuse") return { ok: false, kind: v.kind }; if (v.verdict === "blank" && /\s/.test(n.trim())) strangers.push(asWritten); } @@ -828,7 +840,7 @@ async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: Gu // if any stranger is still there, withhold the whole result. try { const again = normalizeForCheck(redacted); - if ((await findNames(again)).some((n) => isNameLike(n) && !isAllowedPerson(n, again, list))) return { ok: false, kind: "client_name" }; + if ((await findNames(again)).some((n) => isNameLike(n) && !isAllowedPerson(n, again, list, herWords))) return { ok: false, kind: "client_name" }; } catch { return { ok: false, kind: "unavailable" }; } diff --git a/tests/guard-partner-first-names.test.ts b/tests/guard-partner-first-names.test.ts index 557fe24..7e3c642 100644 --- a/tests/guard-partner-first-names.test.ts +++ b/tests/guard-partner-first-names.test.ts @@ -148,6 +148,37 @@ describe("board partners by first name or surname", () => { expect((await guard(withContext(m, "Partners", PICKED), "message", common, ASK)).ok, m).toBe(true); }, T); + // CI on PR #154: plan_referral_meeting's result was withheld now and then. When anything in a + // tool result is blanked (here a stranger), the redacted text is checked again, and that check + // ran the business-only rules (", 9:00 am" read as a bare number) on code-built JSON. Those + // rules are for her own words only. + it("a tool result naming a partner by first name, with times, is kept after another name is blanked", async () => { + const result = JSON.stringify( + { queued: true, proposed: { with: "Maria", kind: "Meeting", when: "Tue Aug 19, 9:00 am" }, also_open: ["Tue Aug 19, 9:30 am", "Tue Aug 19, 10:00 am"], note: "Kevin Ortiz" }, + null, + 2, + ); + const r = await guard(result, "tool_result", allow); + expect(r.ok, JSON.stringify(r)).toBe(true); + if (r.ok) { + expect(r.text).not.toContain("Kevin Ortiz"); + } + // Her own message with the same shape is still judged by the business-only rules. + expect((await guard("coffee with Maria, 9", "message", allow, ASK)).ok).toBe(false); + }, T); + + // The CI flake's real cause: a random approval id whose hex digits read as a phone number. + it("an approval id is never read as a phone number in a full-rules tool result", async () => { + for (const id of ["66d21f71-d43f-48ad-af3c-e18592619355", "4269c074-2ed9-4818-a928-1727490bef4a", "193793dc-f688-40c7-9ecf-ac6564798793"]) { + const text = JSON.stringify({ queued: true, approval_id: id, proposed: { with: "Birinder Malhi, MD", kind: "Meeting", when: "Tue Apr 15, 1:00 pm" } }, null, 2); + const r = await guard(text, "tool_result", allow, { fullRules: true }); + expect(r, id).toEqual({ ok: true, text }); + } + // A real phone number in the same place still refuses. + const phone = JSON.stringify({ note: "her cell is 312-555-0199" }); + expect((await guard(phone, "tool_result", allow, { fullRules: true })).ok).toBe(false); + }, T); + it("every earlier adversarial must-refuse probe still refuses, with these partners on the board too", async () => { const board = { ...DEMO_ALLOWED, names: [...DEMO_ALLOWED.names, ...BOARD], directory: [...DEMO_ALLOWED.directory, ...BOARD] }; const leaks: string[] = []; From a70fe7ba12282d5ded71ca2b90496ddee3007577 Mon Sep 17 00:00:00 2001 From: Isaiah Tennell Date: Tue, 3 Nov 2026 21:49:54 -0600 Subject: [PATCH 4/5] Guard: weekday and month words are never person names Name-finder hits lose weekday/month words at their ends (Mon-Sun, Tue/Tues, Thu/Thur/Thurs, Feb-Dec abbreviations, Sept); month names that are also first names (Jan, May, June, April...) only next to a day number or weekday. Applied to every name-finder read in the guard, so replies and tool results keep times. Co-Authored-By: Claude Opus 5.5 --- docs/BUILD_LOG.md | 1 + lib/aeon/guard.ts | 50 +++++++++++++++++++++++-- tests/guard-partner-first-names.test.ts | 28 +++++++++++++- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/docs/BUILD_LOG.md b/docs/BUILD_LOG.md index fc7c7dd..4e03813 100644 --- a/docs/BUILD_LOG.md +++ b/docs/BUILD_LOG.md @@ -289,3 +289,4 @@ PTSD") is read joined; "identifying" now needs two details (age, job, place) or - 2026-11-03: Partner practice news. The everyday things she says about a partner now pass after she/he/they: opened or moved her practice, hiring a new associate, on vacation or out until a date, asked for my brochure or NPI, has openings, takes a payer, presenting at a conference, co-leading a workshop, mentioned a new group or IOP, and "sees a lot of perinatal anxiety referrals". Each is a fixed business phrase followed only by time and place words, so "he's on vacation in rehab" and "she moved her practice because of her breakdown" still refuse. 22 new smuggles added as tests. - 2026-11-03: Partner practice news, round 4. A business clause about a partner now has to end the sentence (or hand over with ", and she..."): "she's out until Monday, Mercy Hospital" refuses instead of reading the part after the comma as part of the clause. "he said his front desk lost my fax" passes. - 2026-11-03: Fixed a rare false privacy block on Aeon's own meeting results: about 1 in 200 random approval ids has hex digits that read as a phone number ("...-e18592619355"), so the meeting tool's answer was held back now and then. Ids are now read as "[id]" by the privacy check. The business-only rules for partners named by first name also apply only to her own words (message, memory), never to results the code builds. +- 2026-11-03: Weekdays and months are never read as names: a meeting time like "Tue Apr 15, 1:00 pm" in Aeon's answer is no longer blanked to "[name withheld] Apr 15" on machines where the name-finder reads "Tue" as a name. Months that are also first names (May, June, April, Jan) count as dates only next to a day number. diff --git a/lib/aeon/guard.ts b/lib/aeon/guard.ts index c257320..0aabe94 100644 --- a/lib/aeon/guard.ts +++ b/lib/aeon/guard.ts @@ -713,7 +713,7 @@ async function withoutRefusedParts(text: string, list: Allowlist, opts: GuardOpt const restPlain = normalizeForCheck(rest); for (const p of dropped) { const plain = normalizeForCheck(p); - const found = [...(await findNames(plain)), ...(await findNames(titleCase(plain), { secondReads: false }))]; + const found = [...withoutCalendarWords(await findNames(plain), plain), ...withoutCalendarWords(await findNames(titleCase(plain), { secondReads: false }), titleCase(plain))]; for (const n of found.filter(isNameLike)) { if (wordsOf(n).some((w) => w.length > 1 && wholeWord(w, "i").test(restPlain))) return null; } @@ -730,6 +730,48 @@ function joinBrokenLines(text: string): string { return text.replace(/([^.!?:;\s])[ \t]*\n+[ \t]*(?!(?:[-*•]|\d+[.)])\s)/g, "$1 "); } +// Weekdays and months are never a person's name ("Tue Apr 15, 1:00 pm" in a meeting result: +// the name-finder can read "Tue" as one, more often on some machines). Weekday names and the +// abbreviations are always calendar words. Month names that are also first names (Jan, May, +// June, April, August...) count only next to a day number ("May 5", "5th of June") or a weekday. +const ALWAYS_CALENDAR = new Set( + "monday tuesday wednesday thursday friday saturday sunday mon tue tues wed thu thur thurs fri sat sun feb mar apr jun jul aug sep sept oct nov dec".split(" "), +); +const MONTH_NAMES = new Set("jan january february march april may june july august september october november december".split(" ")); +const WEEKDAY_WORD = "(?:mon(?:day)?|tue(?:s(?:day)?)?|wed(?:nesday)?|thu(?:r(?:s(?:day)?)?)?|fri(?:day)?|sat(?:urday)?|sun(?:day)?)"; + +function calendarWord(token: string, text: string): boolean { + const bare = token.replace(/^[^\p{L}]+|[^\p{L}]+$/gu, "").toLowerCase(); + if (ALWAYS_CALENDAR.has(bare)) return true; + if (!MONTH_NAMES.has(bare)) return false; + const spots = [...text.matchAll(new RegExp(`(? 0 && + spots.every((m) => { + const at = m.index ?? 0; + const after = text.slice(at + m[0].length, at + m[0].length + 8); + const before = text.slice(Math.max(0, at - 14), at); + return ( + /^\.?,?\s*\d{1,2}(?:st|nd|rd|th)?(?!\d)/.test(after) || + /\d{1,2}(?:st|nd|rd|th)?\s+(?:of\s+)?$/i.test(before) || + new RegExp(`\\b${WEEKDAY_WORD}\\.?,?\\s+$`, "i").test(before) + ); + }) + ); +} + +/** Name-finder hits with weekday and month words taken off their ends; hits that were only those are dropped. */ +export function withoutCalendarWords(names: string[], text: string): string[] { + const out: string[] = []; + for (const n of names) { + const words = n.split(/\s+/).filter(Boolean); + while (words.length && calendarWord(words[0], text)) words.shift(); + while (words.length && calendarWord(words.at(-1)!, text)) words.pop(); + if (words.length) out.push(words.join(" ")); + } + return out; +} + // A UUID (an approval or card id the code puts in a tool result) is never a phone or record // number, but its hex digits ("...-e18592619355") read as a phone about 1 time in 200: the // checks read "[id]" in its place (normalizeForCheck). @@ -771,8 +813,8 @@ async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: Gu // One name read across a sentence end ("coffee with Maria. Maria's PTSD is worse" gives // "Maria. Maria"): each side is judged on its own, at every place it appears. const split = (list: string[]) => list.flatMap((n) => n.split(/(? p.trim()).filter(Boolean)); - names = split(names); - cased = split(cased); + names = withoutCalendarWords(split(names), plain); + cased = withoutCalendarWords(split(cased), titled); } catch (err) { if (err instanceof Error && err.name === "TooLongToCheck") return { ok: false, kind: "too_long" }; console.error(`[guard] name-finder unavailable: ${err instanceof Error ? err.message : String(err)}`); @@ -840,7 +882,7 @@ async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: Gu // if any stranger is still there, withhold the whole result. try { const again = normalizeForCheck(redacted); - if ((await findNames(again)).some((n) => isNameLike(n) && !isAllowedPerson(n, again, list, herWords))) return { ok: false, kind: "client_name" }; + if (withoutCalendarWords(await findNames(again), again).some((n) => isNameLike(n) && !isAllowedPerson(n, again, list, herWords))) return { ok: false, kind: "client_name" }; } catch { return { ok: false, kind: "unavailable" }; } diff --git a/tests/guard-partner-first-names.test.ts b/tests/guard-partner-first-names.test.ts index 7e3c642..1c6e584 100644 --- a/tests/guard-partner-first-names.test.ts +++ b/tests/guard-partner-first-names.test.ts @@ -7,7 +7,7 @@ import { describe, expect, it } from "vitest"; import { loadEnv } from "../lib/env"; loadEnv(); -const { guard, partnerMatch, whichPartner, looksLikePerson, spokenName } = await import("../lib/aeon/guard"); +const { guard, partnerMatch, whichPartner, looksLikePerson, spokenName, withoutCalendarWords } = await import("../lib/aeon/guard"); const { withContext } = await import("../lib/referrals/ask-context"); const { COMMON_BOARD, REVIEW_MUST_PASS, REVIEW_MUST_REFUSE, ROUND2_MUST_PASS, ROUND2_MUST_REFUSE, ROUND3_MUST_PASS, ROUND3_MUST_REFUSE, ROUND4_MUST_PASS, ROUND4_MUST_REFUSE } = await import("./fixtures/partner-first-names"); const { DEMO_ALLOWED, MUST_REFUSE: ADVERSARIAL_REFUSE } = await import("./fixtures/guard-adversarial"); @@ -179,6 +179,32 @@ describe("board partners by first name or surname", () => { expect((await guard(phone, "tool_result", allow, { fullRules: true })).ok).toBe(false); }, T); + // CI's name-finder read "Tue" in "Tue Apr 15, 1:00 pm" as a name and blanked it. Weekdays and + // months never count as names, whatever the model says. + const DAYS = ["Mon", "Tue", "Tues", "Wed", "Thu", "Thur", "Thurs", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; + const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Sept", "Oct", "Nov", "Dec", "January", "April", "June", "August"]; + + it.each(DAYS.flatMap((d) => MONTHS.map((m) => [d, m])))("never a name: %s %s 15, 1:00 pm", (d, m) => { + const when = `${d} ${m} 15, 1:00 pm`; + const text = JSON.stringify({ proposed: { with: "Birinder Malhi, MD", when }, also_open: [`${d} ${m} 15, 1:30 pm`] }); + expect(withoutCalendarWords([d, m, `${d} ${m}`, `${d} Kevin`], text)).toEqual(["Kevin"]); + }); + + it.each([...DAYS, ...MONTHS])("a meeting time with %s is kept whole in a tool result and a reply", async (w) => { + const when = DAYS.includes(w) ? `${w} Nov 17, 1:00 pm` : `Tue ${w} 17, 1:00 pm`; + const text = JSON.stringify({ queued: true, proposed: { with: "Birinder Malhi, MD", kind: "Meeting", when }, also_open: [when.replace("1:00", "1:30")] }, null, 2); + expect(await guard(text, "tool_result", allow, { fullRules: true })).toEqual({ ok: true, text }); + const reply = `Your meeting with Birinder Malhi, MD is set for ${when}.`; + expect(await guard(reply, "reply", allow)).toEqual({ ok: true, text: reply }); + }, T); + + it("a month that is also a first name is still a name when it isn't a date", async () => { + expect(withoutCalendarWords(["May", "June", "April", "Jan"], "May and June and April and Jan all no-showed")).toEqual(["May", "June", "April", "Jan"]); + expect(withoutCalendarWords(["June"], "coffee on June 5")).toEqual([]); + expect((await guard("June Kowalski no-showed again", "message", allow, ASK)).ok).toBe(false); + expect((await guard("April Nguyen wants Tuesdays after 5", "message", allow, ASK)).ok).toBe(false); + }, T); + it("every earlier adversarial must-refuse probe still refuses, with these partners on the board too", async () => { const board = { ...DEMO_ALLOWED, names: [...DEMO_ALLOWED.names, ...BOARD], directory: [...DEMO_ALLOWED.directory, ...BOARD] }; const leaks: string[] = []; From bca2043235ce46cf7548000e5f89dc21365cb864 Mon Sep 17 00:00:00 2001 From: Isaiah Tennell Date: Tue, 3 Nov 2026 21:55:29 -0600 Subject: [PATCH 5/5] Guard: a bare month first name in a client sentence refuses Capitalized January..December (not a date: no day number, no weekday or in/until/next before it, not 'May I') in a client-like, personal-matter or health sentence refuses at message and memory. Co-Authored-By: Claude Opus 5.5 --- docs/BUILD_LOG.md | 1 + lib/aeon/guard.ts | 21 +++++++++++++++++++++ tests/guard-partner-first-names.test.ts | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/docs/BUILD_LOG.md b/docs/BUILD_LOG.md index 4e03813..f45ef7a 100644 --- a/docs/BUILD_LOG.md +++ b/docs/BUILD_LOG.md @@ -290,3 +290,4 @@ PTSD") is read joined; "identifying" now needs two details (age, job, place) or - 2026-11-03: Partner practice news, round 4. A business clause about a partner now has to end the sentence (or hand over with ", and she..."): "she's out until Monday, Mercy Hospital" refuses instead of reading the part after the comma as part of the clause. "he said his front desk lost my fax" passes. - 2026-11-03: Fixed a rare false privacy block on Aeon's own meeting results: about 1 in 200 random approval ids has hex digits that read as a phone number ("...-e18592619355"), so the meeting tool's answer was held back now and then. Ids are now read as "[id]" by the privacy check. The business-only rules for partners named by first name also apply only to her own words (message, memory), never to results the code builds. - 2026-11-03: Weekdays and months are never read as names: a meeting time like "Tue Apr 15, 1:00 pm" in Aeon's answer is no longer blanked to "[name withheld] Apr 15" on machines where the name-finder reads "Tue" as a name. Months that are also first names (May, June, April, Jan) count as dates only next to a day number. +- 2026-11-03: Month first names. The name-finder misses a bare "June", "May" or "April" used as a name, so "June no-showed again" and "April's PTSD is worse" passed. Now a capitalized month that is not a date (no day number beside it, no weekday or "in/until/next" before it) in a client or personal sentence refuses, in her message and in memory. "meet in May", "follow up May 5" and a board partner named June Park still pass. diff --git a/lib/aeon/guard.ts b/lib/aeon/guard.ts index 0aabe94..c2e8101 100644 --- a/lib/aeon/guard.ts +++ b/lib/aeon/guard.ts @@ -829,6 +829,27 @@ async function checkOnce(text: string, at: GuardPoint, list: Allowlist, opts: Gu const s = sentenceAt(plain, t.at); if (MY_CLIENT.test(s) || clientLike(s) || PERSONAL_MATTER.test(s) || !businessOnly(s)) return { ok: false, kind: "client_name" }; } + // A month that is also a first name ("June no-showed again", "May cried in session", + // "April's PTSD is worse"): the name-finder often misses it. Capitalized, not a date (no day + // number beside it, no weekday before it), in a client or personal sentence: refused like + // any unknown name. "meet in May", "follow up May 5" and "May I ask..." are not names. + for (const t of tokensOf(plain)) { + if (!t.capital || !MONTH_NAMES.has(t.base) || calendarWord(t.base, plain)) continue; + if (t.base === "may" && /^\s+(?:I|we|you|she|he|they)\b/i.test(plain.slice(t.end))) continue; + // "starting in June", "until April", "next May", "end of August": the month. + if (/\b(?:in|by|until|till|through|since|during|before|after|from|of|next|last|this|early|mid|late|starting|beginning|end\s+of)\s+$/i.test(plain.slice(Math.max(0, t.at - 16), t.at))) continue; + const s = sentenceAt(plain, t.at); + if ( + MY_CLIENT.test(s) || + clientLike(s) || + PERSONAL_MATTER.test(s) || + mentionsDiagnosis(s) || + medicalAboutSomeone(s) || + namedCondition(plain.slice(t.at, t.end), s) + ) { + return { ok: false, kind: mentionsDiagnosis(s) ? "diagnosis" : "client_name" }; + } + } } const strangers: string[] = []; // Her partners named by first name or surname (partnerMatch): one card each passes; diff --git a/tests/guard-partner-first-names.test.ts b/tests/guard-partner-first-names.test.ts index 1c6e584..38e464a 100644 --- a/tests/guard-partner-first-names.test.ts +++ b/tests/guard-partner-first-names.test.ts @@ -205,6 +205,30 @@ describe("board partners by first name or surname", () => { expect((await guard("April Nguyen wants Tuesdays after 5", "message", allow, ASK)).ok).toBe(false); }, T); + // The name-finder misses a bare month first name: refused by plain code, at message and memory. + it.each([ + "June no-showed again", + "May cried in session", + "April's PTSD is worse", + "April wants Tuesdays after 5", + "August owes me for two sessions", + "my client June wants a meeting", + "January is struggling since her divorce", + ])("a bare month first name in a client sentence refuses: %s", async (m) => { + for (const at of ["message", "memory"] as const) { + const r = await guard(m, at, allow, ASK); + expect(r.ok, `${at}: ${m}`).toBe(false); + } + }, T); + + it("a month that is a date, or a board partner named June, still passes", async () => { + const board = [...BOARD, "[Sample] June Park, LCSW"]; + const withJune = { names: [...OWN, ...board], contacts: [], directory: board }; + for (const m of ["coffee with June Park", "meet in May", "follow up May 5", "May I book a coffee with Maria?", "we start a grief group in June", "lunch talk with Pamela next April"]) { + expect((await guard(m, "message", withJune, ASK)).ok, m).toBe(true); + } + }, T); + it("every earlier adversarial must-refuse probe still refuses, with these partners on the board too", async () => { const board = { ...DEMO_ALLOWED, names: [...DEMO_ALLOWED.names, ...BOARD], directory: [...DEMO_ALLOWED.directory, ...BOARD] }; const leaks: string[] = [];