Skip to content

fix(sharing,runtime): a sort passed straight to the engine never ordered anything; migrate in-repo call sites to canonical keys (#4346) - #4370

Merged
os-zhuang merged 1 commit into
mainfrom
claude/migrate-filter-callsites-to-where
Jul 31, 2026
Merged

fix(sharing,runtime): a sort passed straight to the engine never ordered anything; migrate in-repo call sites to canonical keys (#4346)#4370
os-zhuang merged 1 commit into
mainfrom
claude/migrate-filter-callsites-to-where

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

#4346 的收尾清扫。原计划是"把仓内 {filter} 调用迁到 where"的机械 PR,但扫描扫出了三个活 bug,所以这个 PR 有两种性质的改动。

一、活 bug:直连引擎的 sort 从未排过序

#4346 让引擎在六个方法上折叠 filterwheretoplimitRPC_QUERY_ALIAS_SLOTS另外四对(select/sort/skip/populate)只在 RPC/wire 层折叠——它们的值需要形状降级(sort 的 record 形式、populate 的名字列表),那属于那一层的职责——而直接调 engine.find() 根本不经过那一层

三处调用在那里传了 sort,于是它原样骑在 AST 上,每个 driver 的 Array.isArray(query.orderBy) 守卫都拒绝生成 ORDER BY:

调用点要的实际拿到
share-link-routes.ts分享出去的 AI 会话消息,created_at asc消息乱序
runtime/domains/share-links.ts同一路由的 runtime 副本同上
share-link-service.tslistLinks最近 200 条分享链接任意 200 条

三处都是"丢掉的排序 + limit"——正是 #4226 注释点名的 "latest N" 失败模式:未生效的排序返回任意顺序,limit 再把它切成任意一页,而响应看起来完全正常。#4226 修的是 wire 归一化器,这三处在它下面一层。

如何确证的(不靠读代码):写了运行时探针,用真实引擎 + 记录型 driver 打印引擎实际收到的 AST ——

>>> AST keys: object,sort,limit
>>> ast.orderBy = undefined
>>> ast.sort = [{"field":"created_at","order":"asc"}]

针脚:listLinks 此前没有任何测试,这是它坏了这么久没人发现的原因。新针脚断言引擎收到的选项包而非行顺序——因为失败点是"这个键从未变成 orderBy",而一个两种拼写都认的测试替身无论如何都会通过。保留前先把修复临时回退,确认针脚会变红(expected undefined to deeply equal [...]),不是恒绿装饰。

二、清理:27 处空操作重命名

其余 27 处引擎调用的 filter 改为 where(approvals 5、auth 2、reports 6、sharing 11、webhooks 2,外加 spec 一处文档示例)。因 #4346 已折叠,这些是严格的空操作——意义在于框架不再依赖它要求用户迁离的拼写,这是将来退役别名的前置条件。

三、一处测试替身必须同步

approver-org-scope 的假引擎读 opts.filter,所以它一直通过仅仅因为替身和生产代码讲同一种废弃方言。这正是让整类问题得以长期存活的机制,值得单独记一笔。已改为读规范键。顺带全仓扫了其他替身:多数读 opts.where ?? opts.filter(有韧性),无其他需要同步的。

验证

plugin-sharing 226 ✅ / plugin-approvals 330 ✅ / plugin-auth 579 ✅ / plugin-reports 50 ✅ / plugin-webhooks 25 ✅ / runtime 974 ✅ / spec 7160 ✅ / objectql 1450 ✅;改动包 typecheck ✅;check:docs ✅(生成物无漂移)。

遗留

另外四对别名在引擎层依然静默失效——一个未来的调用者写 select/skip/populate 会踩同样的坑,而选项类型是 any,编译期抓不到。这个更深的缺口(引擎应当对无法理解的查询键报错而非静默忽略)会按 PD #10 单独开 issue,不在本 PR 扩大范围。

Refs #4346, #4226, #3795.

🤖 Generated with Claude Code

…dered anything (#4346)
Sweeping every in-repo engine call site that still spoke a deprecated alias
turned up three that were not cosmetic.
#4346 made the engine fold `filter`→`where` and `top`→`limit` on all six
methods. The remaining four pairs in RPC_QUERY_ALIAS_SLOTS (select, sort,
skip, populate) fold at the RPC/wire layer only — their values need shape
lowering that belongs to those layers — and a DIRECT engine.find() never
crosses that layer. Three call sites passed `sort` there, so it rode onto the
AST untouched, every driver's `Array.isArray(query.orderBy)` guard declined to
emit an ORDER BY, and the read returned an ordinary-looking, arbitrarily
ordered result:
share-link-routes.ts shared AI conversation messages, created_at asc
runtime/domains/share-links.ts the same route, runtime-domain copy
share-link-service.ts listLinks: "the 200 most recent" share links
Each pairs the dropped sort with a limit — the "latest N" shape whose failure
#4226 spelled out, one layer below the normalizer #4226 fixed. listLinks had
no test at all, which is why it went unnoticed; it is pinned now on the option
bag the engine RECEIVES, not on row order, because the failure is that the key
never becomes `orderBy` and a double honouring either spelling passes either
way. Verified the pin fails against the pre-fix line before keeping it.
The other 27 sites are strict no-ops since #4346 folds `filter`: approvals 5,
auth 2, reports 6, sharing 11, webhooks 2, plus a spec doc example teaching
`filters` (a wire-only alias the engine does not fold at all, so the example
taught a call that matches every row). Renaming them stops the framework
depending on a spelling it asks users to migrate off. Service-level `filter`
PARAMETERS — each service's own public API — are deliberately untouched.
One test double had to move with them: approver-org-scope's fake engine read
`opts.filter`, so it kept passing only because both sides shared the
deprecated dialect. That is the mechanism that let the whole class persist.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercelBot commented Jul 31, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectstackIgnoredIgnoredJul 31, 2026 9:20am

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation protocol:system size/m tests tooling labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 7 package(s): @objectstack/plugin-approvals, @objectstack/plugin-auth, @objectstack/plugin-reports, @objectstack/plugin-sharing, @objectstack/plugin-webhooks, @objectstack/runtime, @objectstack/spec.

115 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/ai/agents.mdx(via @objectstack/spec)
  • content/docs/ai/skills-reference.mdx(via @objectstack/spec)
  • content/docs/ai/skills.mdx(via @objectstack/spec)
  • content/docs/api/client-sdk.mdx(via @objectstack/plugin-reports, packages/runtime, @objectstack/spec)
  • content/docs/api/environment-routing.mdx(via @objectstack/spec)
  • content/docs/api/error-catalog.mdx(via @objectstack/spec)
  • content/docs/api/error-handling-client.mdx(via @objectstack/spec)
  • content/docs/api/error-handling-server.mdx(via @objectstack/spec)
  • content/docs/api/index.mdx(via @objectstack/runtime, @objectstack/spec)
  • content/docs/api/wire-format.mdx(via @objectstack/runtime)
  • content/docs/automation/approvals.mdx(via @objectstack/plugin-approvals, @objectstack/spec)
  • content/docs/automation/connectors.mdx(via @objectstack/spec)
  • content/docs/automation/flows.mdx(via @objectstack/spec)
  • content/docs/automation/hook-bodies.mdx(via @objectstack/runtime, packages/spec)
  • content/docs/automation/hooks.mdx(via @objectstack/spec)
  • content/docs/automation/index.mdx(via @objectstack/spec)
  • content/docs/automation/webhooks.mdx(via packages/plugins/plugin-webhooks, @objectstack/spec)
  • content/docs/automation/workflows.mdx(via @objectstack/spec)
  • content/docs/concepts/architecture.mdx(via @objectstack/spec)
  • content/docs/concepts/design-principles.mdx(via packages/spec)
  • content/docs/concepts/index.mdx(via @objectstack/spec)
  • content/docs/concepts/metadata-driven.mdx(via @objectstack/spec)
  • content/docs/concepts/metadata-lifecycle.mdx(via @objectstack/runtime, packages/spec)
  • content/docs/concepts/north-star.mdx(via packages/runtime, packages/spec)
  • content/docs/data-modeling/analytics.mdx(via @objectstack/spec)
  • content/docs/data-modeling/drivers.mdx(via @objectstack/runtime, @objectstack/spec)
  • content/docs/data-modeling/external-datasources.mdx(via @objectstack/spec)
  • content/docs/data-modeling/field-types.mdx(via @objectstack/spec)
  • content/docs/data-modeling/fields.mdx(via @objectstack/spec)
  • content/docs/data-modeling/formulas.mdx(via @objectstack/spec)
  • content/docs/data-modeling/index.mdx(via @objectstack/spec)
  • content/docs/data-modeling/objects.mdx(via @objectstack/spec)
  • content/docs/data-modeling/queries.mdx(via @objectstack/spec)
  • content/docs/data-modeling/schema-design.mdx(via @objectstack/spec)
  • content/docs/data-modeling/seed-data.mdx(via @objectstack/spec)
  • content/docs/data-modeling/validation-rules.mdx(via @objectstack/spec)
  • content/docs/data-modeling/validation.mdx(via @objectstack/spec)
  • content/docs/deployment/cli.mdx(via @objectstack/plugin-auth, @objectstack/spec)
  • content/docs/deployment/index.mdx(via @objectstack/runtime)
  • content/docs/deployment/production-readiness.mdx(via @objectstack/plugin-auth, @objectstack/runtime)
  • content/docs/deployment/single-project-mode.mdx(via @objectstack/runtime)
  • content/docs/deployment/troubleshooting.mdx(via @objectstack/spec)
  • content/docs/deployment/validating-metadata.mdx(via @objectstack/spec)
  • content/docs/deployment/vercel.mdx(via @objectstack/runtime)
  • content/docs/getting-started/build-with-claude-code.mdx(via @objectstack/spec)
  • content/docs/getting-started/common-patterns.mdx(via @objectstack/spec)
  • content/docs/getting-started/examples.mdx(via @objectstack/spec)
  • content/docs/getting-started/quick-reference.mdx(via @objectstack/spec)
  • content/docs/getting-started/quick-start.mdx(via @objectstack/spec)
  • content/docs/getting-started/your-first-project.mdx(via @objectstack/runtime, @objectstack/spec)
  • content/docs/kernel/cluster.mdx(via @objectstack/runtime, @objectstack/spec)
  • content/docs/kernel/contracts/auth-service.mdx(via packages/spec)
  • content/docs/kernel/contracts/cache-service.mdx(via packages/spec)
  • content/docs/kernel/contracts/data-engine.mdx(via @objectstack/spec)
  • content/docs/kernel/contracts/index.mdx(via @objectstack/spec)
  • content/docs/kernel/contracts/metadata-service.mdx(via packages/spec)
  • content/docs/kernel/contracts/storage-service.mdx(via packages/spec)
  • content/docs/kernel/index.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/email-service.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/index.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/queue-service.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/sharing-service.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/sms-service.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/storage-service.mdx(via packages/spec)
  • content/docs/kernel/services-checklist.mdx(via @objectstack/plugin-approvals, @objectstack/plugin-auth, @objectstack/plugin-sharing, @objectstack/spec)
  • content/docs/kernel/services.mdx(via @objectstack/spec)
  • content/docs/permissions/authentication.mdx(via @objectstack/plugin-auth, @objectstack/runtime)
  • content/docs/permissions/authorization.mdx(via packages/plugins/plugin-sharing, packages/runtime, @objectstack/spec)
  • content/docs/permissions/permission-sets.mdx(via @objectstack/spec)
  • content/docs/permissions/permissions-matrix.mdx(via packages/plugins/plugin-sharing, @objectstack/spec)
  • content/docs/permissions/positions.mdx(via @objectstack/spec)
  • content/docs/permissions/rls.mdx(via @objectstack/spec)
  • content/docs/permissions/sharing-rules.mdx(via @objectstack/spec)
  • content/docs/permissions/sso.mdx(via @objectstack/plugin-auth)
  • content/docs/plugins/adding-a-metadata-type.mdx(via @objectstack/spec)
  • content/docs/plugins/development.mdx(via @objectstack/spec)
  • content/docs/plugins/index.mdx(via @objectstack/plugin-auth, @objectstack/spec)
  • content/docs/plugins/packages.mdx(via @objectstack/plugin-approvals, @objectstack/plugin-auth, @objectstack/plugin-reports, @objectstack/plugin-sharing, @objectstack/plugin-webhooks, @objectstack/runtime, @objectstack/spec)
  • content/docs/protocol/backward-compatibility.mdx(via @objectstack/spec)
  • content/docs/protocol/diagram.mdx(via packages/spec)
  • content/docs/protocol/kernel/config-resolution.mdx(via @objectstack/spec)
  • content/docs/protocol/kernel/http-protocol.mdx(via @objectstack/plugin-auth, @objectstack/runtime)
  • content/docs/protocol/kernel/i18n-standard.mdx(via @objectstack/spec)
  • content/docs/protocol/kernel/index.mdx(via @objectstack/runtime, @objectstack/spec)
  • content/docs/protocol/kernel/lifecycle.mdx(via @objectstack/runtime, @objectstack/spec)
  • content/docs/protocol/kernel/plugin-spec.mdx(via @objectstack/spec)
  • content/docs/protocol/kernel/runtime-capabilities.mdx(via @objectstack/spec)
  • content/docs/protocol/knowledge.mdx(via @objectstack/spec)
  • content/docs/protocol/objectql/index.mdx(via @objectstack/spec)
  • content/docs/protocol/objectql/query-syntax.mdx(via @objectstack/spec)
  • content/docs/protocol/objectql/schema.mdx(via @objectstack/spec)
  • content/docs/protocol/objectql/security.mdx(via packages/plugins/plugin-sharing, packages/spec)
  • content/docs/protocol/objectql/state-machine.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/actions.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/concept.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/index.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/layout-dsl.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/record-alert.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/widget-contract.mdx(via @objectstack/spec)
  • content/docs/releases/implementation-status.mdx(via @objectstack/plugin-approvals, @objectstack/plugin-auth, @objectstack/plugin-sharing, @objectstack/plugin-webhooks, @objectstack/runtime, @objectstack/spec)
  • content/docs/releases/index.mdx(via @objectstack/spec)
  • content/docs/releases/v12.mdx(via @objectstack/spec)
  • content/docs/releases/v13.mdx(via @objectstack/spec)
  • content/docs/releases/v16.mdx(via @objectstack/spec)
  • content/docs/releases/v17.mdx(via @objectstack/spec)
  • content/docs/releases/v9.mdx(via @objectstack/plugin-approvals, @objectstack/plugin-auth, @objectstack/spec)
  • content/docs/ui/actions.mdx(via @objectstack/spec)
  • content/docs/ui/create-vs-edit-form.mdx(via @objectstack/spec)
  • content/docs/ui/dashboards.mdx(via @objectstack/spec)
  • content/docs/ui/forms.mdx(via @objectstack/spec)
  • content/docs/ui/index.mdx(via @objectstack/spec)
  • content/docs/ui/public-data-collection.mdx(via @objectstack/spec)
  • content/docs/ui/setup-app.mdx(via @objectstack/spec)
  • content/docs/ui/translations.mdx(via @objectstack/spec)
  • content/docs/ui/views.mdx(via @objectstack/spec)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang

Copy link
Copy Markdown
ContributorAuthor

遗留缺口已按 PD #10 单独立案:#4371 —— 直连引擎调用会静默丢弃另外四对别名(sort/select/skip/populate),本 PR 修的三处正是它的实例。不在本 PR 扩大范围。

@os-zhuang
os-zhuang merged commit b5f9397 into mainJul 31, 2026
18 checks passed
@os-zhuang
os-zhuang deleted the claude/migrate-filter-callsites-to-where branch July 31, 2026 09:34
os-zhuang added a commit that referenced this pull request Jul 31, 2026
…e now throws instead of silently dropping it (#4371) (#4387)
The engine folds filter→where and top→limit itself (#4346); the other four
pairs in RPC_QUERY_ALIAS_SLOTS fold at the RPC/protocol layer only, because
their value shapes need lowering that belongs there. A direct engine.find()
never crosses that layer, so the alias key rode the AST verbatim, drivers
read only the canonical name, and the request succeeded with the parameter
silently discarded — three shipped instances fixed in #4370, and a fourth
in the engine's own seedAutonumber (select — its projection never applied,
and the surrounding catch would have swallowed the new rejection into
'seed from 0', i.e. duplicate autonumbers; now passes fields).
find/findOne now reject a non-null wire-only spelling with an error naming
the canonical key, the layer that owns the fold, and the target shape.
Folding them here instead would re-implement the RPC layer's shape lowering
per reader — the #3795 condition — so rejecting keeps one fold, one owner.
The where-only methods (update/delete/count/aggregate) are deliberately
unchanged: their contracts honour no sort/projection/pagination in either
spelling, so 'pass orderBy instead' would redirect to a key they silently
ignore too — that is #4371 option (2), scoped separately.
Call-site survey (this repo + cloud): zero direct callers pass these keys
today; every wire ingress folds at the protocol layer (pinned end-to-end).
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationprotocol:systemsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@os-zhuang