Skip to content

fix(plugin-audit): match an @mention email case-insensitively - #27751

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-rcp68o
Oct 29, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-rcp68o

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #27503

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:评论里按邮箱 @提及同事时,邮箱改为不区分大小写匹配(先去首尾空格再转小写),与登录查找用户的方式一致。
  • 为什么改:以前按原样精确匹配,大小写不同的地址(例如 Carol@Example.com)评论照样 201 成功,但被提及的人永远收不到通知,作者也看不到任何报错。
  • 风险与回滚:风险低,只改了一处查询条件;谁能收到通知仍由记录与评论的读权限决定,没有放宽。回滚即 revert 本 PR。
  • 先看:packages/plugins/plugin-audit/src/mention-recipient-gate.ts 里 resolveMentionedUser 的 where 那一行;然后看 mention-recipient-gate.integration.test.ts 新增的两个用例。
  • 两分钟验证:pnpm --filter @objectstack/plugin-audit exec vitest run src/mention-recipient-gate.integration.test.ts,预期 Tests 17 passed (17)。
  • 需要你做的:无,席位落地。

What changes

resolveMentionedUser (plugin-audit's @mention recipient gate) looked an email-shaped mention up with where: { email: value }, an exact match on sys_user.email. Identity stores that column lowercased, so G4B.MEMBER@EXAMPLE.COM resolved nobody. The comment was still accepted with 201, and the gate logged mention notification withheld with reason unknown_email.

The lookup now passes the address through normalizePlatformAdminEmail from @objectstack/core. That is the one exported email normalisation in core (trim, then lowercase), and it is already the comparison the platform-admin derivation and the Layer 0 wall use. For an address that has already been trimmed, it gives exactly the spelling sign-in queries:

  • findSignInAccount (plugin-auth) queries where: { email: email.toLowerCase() };
  • better-auth's /sign-in/email calls internalAdapter.findUserByEmail(email.toLowerCase()), and createUser / updateUser write email.toLowerCase(), so stored addresses are already normalised.

No second matcher is added. Who may be notified does not change: the record read and the comment read in the mentioned user's own envelope still decide.

Tests

packages/plugins/plugin-audit/src/mention-recipient-gate.integration.test.ts (real kernel, ObjectQL, SQLite driver, AuditPlugin) gets two new cases:

  • isolated: a comment mentioning Carol@A.Test, and one mentioning CAROL@A.TEST with spaces around it, each notify the user stored as carol@a.test. Both go through the real afterInsert mention writer.
  • withheld-recipient log: admitMentionRecipients with CAROL@A.TEST admits CAROL and logs nothing, so there is no unknown_email.

Acceptance notes

  • Normaliser name. normalizePlatformAdminEmail carries a platform-admin name, but its docblock calls it the one email normalisation, and it is the only exported one in @objectstack/core. Renaming it is a naming question only, so no card was filed.
  • Rows outside identity. A sys_user row written with a mixed-case email outside the identity write paths (for example a raw system-context insert) cannot be found by sign-in. After this change it cannot be found by a mention either, so a mention now reaches exactly the users sign-in reaches.
  • Unknown user ids. The card's diagnostic-only note says an unknown user id (mentions: ["nosuchuser123"]) is logged as cannot_read_thread. It is unchanged here: it affects only the log text, and nobody is notified who should not be. This is an observation, not filed.
  • Fresh origin/main. origin/main moved after the single merge (to 34dc09b68). The only family file that changed in that range is scripts/check-route-envelope.mjs, and it is not one this diff derives. CI runs on the merged head.

Verification

All readings are on head e7119109 (fix commit 5febd38e plus one merge of origin/main ef359b95).

Red before the fix (built closure, test only)
× resolves an email mention whatever its casing, the way sign-in finds the user
× logs no unknown_email for a differently-cased address of a stored user
AssertionError: expected [] to deeply equal [ [ 'u_carol' ] ]
Tests  2 failed | 15 passed (17)
Green after the fix
Test Files  1 passed (1)
     Tests  17 passed (17)
os-verify-lock: VERDICT command-exit 0
Ablation (fix committed first; scripts/ablation-replace.mjs; suite resolves core and this package from src, so no dist leg)
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 8f07337134ce -> e29091174dd9
× resolves an email mention whatever its casing, the way sign-in finds the user
× logs no unknown_email for a differently-cased address of a stored user
Tests  2 failed | 15 passed (17)
ablation-replace: ok restored: blob == HEAD (8f07337134ce) and `git diff HEAD` is empty
Package test, typecheck, lint (head e711910)
pnpm --filter @objectstack/plugin-audit test       -> Test Files 65 passed (65) · Tests 1051 passed (1051) · VERDICT command-exit 0
pnpm --filter @objectstack/plugin-audit typecheck  -> VERDICT command-exit 0 (check:test-typecheck OK, 0 debt)
eslint --no-inline-config (the two changed .ts files) -> exit 0, no output
Derived gate families (dispatch-gates --commands, 61 commands, head e711910)
61 run, 61 exit 0
dispatch-gates --ran: 61 derived famil(ies) accounted for — 61 run, 0 NOT-MEASURED

On the first pass three commands exited 3 (PREREQUISITE NOT MET, nothing was measured). Each was re-run after its prerequisite was met:

  • check-plugin-teardown-shape --self-test: fetched the pinned fixture commit, then exit 0 (48 cases).
  • check:i18n: built its stated closure, then exit 0 (10 packages in sync).
  • check:dual-build-cjs-loads: full pnpm build (114 tasks), then exit 0 (112 entries across 69 packages).

The PR's check-runs cover all other CI families.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4czuTWNgKR22fKv7jia

An email-shaped mention was looked up with an exact match on
sys_user.email, so a differently-cased address resolved nobody and the
colleague was silently never notified. Normalise it with the shared
email normalisation (trim, then lowercase) before the lookup, the same
spelling identity stores and sign-in queries.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czuTWNgKR22fKv7jia
@github-actions github-actions Bot added size/s documentation Improvements or additions to documentation tests tooling labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 58 of 210 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 9794c41ec66785b13d061cdcf1a6ea8a4052a5c1 — the merge of head e711910983d66be94059b99aa485bff340c4a016 into base 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 9794c41ec66785b13d061cdcf1a6ea8a4052a5c1 && git checkout 9794c41ec66785b13d061cdcf1a6ea8a4052a5c1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65 e711910983d66be94059b99aa485bff340c4a016 && git checkout -B drift-repro 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65 && git merge --no-ff e711910983d66be94059b99aa485bff340c4a016

node scripts/docs-audit/affected-docs.mjs --json 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia

Seat ACCEPT · PR #27751 · head e711910983d66be94059b99aa485bff340c4a016 · 2026-10-29T22:39Z

席位核对

  • Shape: draft → main; Fixes #27503 is the right relation (the whole card lands). Files: mention-recipient-gate.ts, its integration test, one changeset; nothing unrelated. check-governed-merges --pr 27751: NOT governed, 41 changed lines.
  • Premise measured: the exact-match lookup on origin/main; stored emails are lowercased by identity and sign-in queries the lowercased address. The fix reuses the shared normalizePlatformAdminEmail (no second matcher, per triage 6495269327). The two new cases were red before the fix and green after, and the ablation was restored.
  • Gate check-runs on this head: 48 total, 35 success, 13 skipped by the path filter, 0 failed.
  • Accepted deviations: assignees: [] dropped from pr_create (the relay refuses an empty list); the footer follows the dispatch wording.
  • Declarations: Clause-②: no, Metadata-protocol: none — right. More mentions resolve; who may be notified is still decided by the read checks, so no accept set narrows and no published surface moves. No contract review owed.
  • Changeset read sentence by sentence: it matches the diff (trim then lowercase through normalizePlatformAdminEmail; read checks unchanged).
  • Out of scope: two notes, neither filed (outside the filing classes: log text only, and a naming-only point). They are recorded in the PR's Acceptance notes.
  • Landing: Tier S, under the maintainer's landing grant for this term (2026-10-29 22:05Z, seat thread). Ready + auto-merge through the relay.

ACCEPT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

comments: an @mention by email is matched case-sensitively, so a differently-cased address is accepted 201 and silently never notified

1 participant