Skip to content

[finding] TemplateLoader 的 docblock 开头说「best-matching row」,而 spec 契约逐字写着「There is no "best match"」—— 同一段注释两行后又说 EXACT match #19507

Description

@huangyiirene

Path: none | 契约文本与实现注释不一致(plugin-email) | 北极星「优先级」4

由 domain:services 席(session_01AhQASwqJr2Z7XfGWUdvnbF)在 #18499 的交付中作顺路发现立卡。证据为本席独立现验,⛔ 非转述。⛔ 未分诊、⛔ 无 domain:*、⛔ 无定级。

class: b(违背已声明契约)

缺陷

packages/plugins/plugin-email/src/email-service.ts 的 TemplateLoader 接口 docblock 开头第一句:

 * Loader for sys_email_template rows. Injected by EmailServicePlugin
 * on `kernel:ready`. Returns the best-matching row for `(name, locale)`
 * or `null` when none exists / inactive.
 *
 * `locale` set → an EXACT match for that locale, or `null`; the en-US fallback

⇒ 同一段注释里自相矛盾:开头说「best-matching row」,两行后又正确地说「an EXACT match」。

它违背的已声明契约(逐字)

packages/spec/src/contracts/email-service.ts,SendTemplateInput.template 的 describe:

Template identifier (matches sys_email_template.name) … There is no "best match" and no language-subtag folding: the locale row is resolved by the exact ladder documented on locale below.

为什么它不在 #18499 里一并修

#18499 的载体集是用探针 best-matching locale|picks the best 枚举出来的,而这句写的是「best-matching row」—— 不在那个探针的命中集内。⇒ 它是同类的第四处,但不是那张卡点名的载体,顺手改会把那张卡的范围撑开。

⭐ 这也是一条关于探针的读数:一个按字面串枚举载体的集合,对同义改写是盲的。修本卡时值得连带问一句:还有没有第五种拼法。

为什么它咬人

该 docblock 随 dist 出货(plugin-email/dist/index.d.ts),⇒ 集成方在 IDE 里读到的就是它。一个在 IDE 里说「best match」、在契约里说「no best match」的接口,会让调用方按不存在的回退行为写代码。

Seam: spec:SendTemplateInput.template → runtime:EmailService.resolveAndRenderTemplate | renderer: none

查重词

TemplateLoader best-matching row · email-service.ts loader docblock best match · plugin-email interface docblock locale · best-matching row (name, locale) · email loader docblock contradicts contract

出处:#18499 / PR #19504 的交付。


Generated by Claude Code

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions