Skip to content

[docs] services.data 页的 Example 也是 hook 语境混搭 —— ctx.input.contact_id 配上 hook 拿不到的 services.data #5944

Closed

Description

@os-zhuang

事实(对 origin/main 核实)

content/docs/kernel/runtime-services/data-service.mdx:42-51:

## Example

const contact = await services.data.get('contact', ctx.input.contact_id);
const orders = await services.data.find('sales_order', {
  filter: { contact_id: contact.id },
  sort: [{ field: 'created_at', order: 'desc' }],
  top: 20,
});

ctx.input.… 只有 hook 上下文(和沙箱 body)才有这个读法,而 hook 上下文没有 services 键 —— #5720 已实测钉死:引擎五处 hookContext 构造点逐键构造(object / event / input / session / provenance / user / api / transaction / ql),buildHookSandboxContext 同样不产;把示例按 (ctx: HookContext) 如实标注即 TS2339: Property 'services' does not exist。

即这段 Example 把「hook 的 ctx.input」和「hook 拿不到的 services.data」拼在一起,和 #5720 修掉的 examples.mdx / sharing-service.mdx 是同一族缺陷,只是这一页没被 #5720 的裁定与派发面点名(#5720 的 PR #5938 严格按派发面只改那两页,故此处按 PD #10 单独记录,未夹带)。

为什么仍算缺陷

services.data 本身不是幻觉:runtime-services 索引页的 binding note 写明这是契约签名面,开放框架不往 hook ctx 注入 services,托管运行时才提供该绑定。缺陷在于 Example 用 ctx.input 把它写成了 hook 代码 —— 照抄进 hook 会在 services 上 TypeError(比 #5720 的「无条件 403」响,但同样是文档教了运行时不交付的形状)。

顺带一处措辞待核:同页 - **Canonical source:** packages/client/src/index.ts 指的是客户端 SDK,与「runtime service」标题的关系值得在修这页时一并说清。

建议修法(与 #5720 已落地的形状对齐)

PR #5938 给这两页定了模式,照搬即可:

关联

未加标签、未认领,交 PM 分诊定级。

Activity

  1. added
    domain:devxDomain lane — seat card indexed by label:pm:seat
    pm:queueReady for the PM dispatch loop
    on Aug 6, 2026
  2. claude commented on Aug 6, 2026

    @claude
    Contributor

    分诊:pm:queue + domain:devx。

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  3. self-assigned this
    on Aug 6, 2026
  4. hotlong commented on Aug 6, 2026

    @hotlong
    Contributor

    认领:PM 循环第 1 轮(devx 车道)
    会话:session_01BDmDsu2575gDxeMCxXhDE3
    分支:claude/issue-5944-data-service-example
    Worktree:objectstack-issue-5944
    域:domain:devx
    文件面:content/docs/kernel/runtime-services/data-service.mdx、.changeset/(越界即停,报告说明)

    照 #5720 / PR #5938 已落地的模式改;⚠️ os:check 标记的取舍受 #5945(HookContext.api 为 z.unknown)裁决约束,⛔ 不为补标记抢跑窄化 ctx.api。


    Generated by Claude Code

  5. hotlong commented on Aug 6, 2026

    @hotlong
    Contributor

    验收(devx 车道,会话 session_01BDmDsu2575gDxeMCxXhDE3):ACCEPT → PR #5995,已转 ready 并挂入合并队列。

    交付摘要:


    Generated by Claude Code

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

Metadata

Metadata

Assignees

Labels

domain:devxDomain lane — seat card indexed by label:pm:seatpm:dispatchedDispatched to a dev agent by /pm-dispatchpm:queueReady for the PM dispatch loop

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions